I am trying to run my code.
from lithops.multiprocessing import Pool
import time
import s3fs
s3 = s3fs.S3FileSystem(anon=True)
def count_words(lines):
count = 0
for line in lines:
line = line.rstrip()
pieces = line.split()
for initial_word in pieces:
word = ''.join(c for c in initial_word if c.isalpha())
if word: # Skip empty words
count = count + 1
return count
if name == 'main':
fhand = s3.open('lithops-data-yey/notsobigtextfile_small.txt')
start = time.perf_counter()
word_number = 0
lines_per_chunk = 1000 # Number of lines to process per chunk
with Pool() as p:
chunks = []
while True:
chunk = []
for _ in range(lines_per_chunk):
line = fhand.readline()
if not line:
break
chunk.append(line)
if not chunk:
break
chunks.append(chunk)
line_numbers = p.map(count_words, chunks)
word_number = sum(line_numbers)
print('Word Count:', word_number)
finish = time.perf_counter()
print(f'Finished in {round(finish - start, 2)} second(s)')
I want to figure out why I get the error on the line
fhand = s3.open('lithops-data-yey/notsobigtextfile_small.txt')
I've made sure my credentials file is correct and don't know how to proceed.
This is the error I get:
Exception has occurred: PermissionError
Forbidden
botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
The above exception was the direct cause of the following exception:
File "/Users/oanamoc/Desktop/Work/lithops/task1 copy.py", line 20, in <module>
fhand = s3.open('lithops-data-yey/notsobigtextfile_small.txt')
PermissionError: Forbidden
How do I make sure of that?