So I have this code:
from pathlib import PosixPath
import numpy as np
import re
import os
import json
import s3fs
import argparse
import sagemaker
import cv2
import random
import boto3
import botocore
import tensorflow as tf
print(f"tensorflow: {tf.__version__}")
import pandas as pd
from tensorflow import keras
from tensorflow.keras.layers.experimental.preprocessing import RandomFlip, RandomRotation
import boto3
from pathlib import Path
from sagemaker.tensorflow import TensorFlow
if __name__ == "__main__":
s3=boto3.resource('s3')
for bucket in s3.buckets.all():
print(bucket.name) # this does list all of my buckets.
my_bucket=s3.Bucket(bucket.name)
for file in my_bucket.objects.all():
print(file.key)
this lists all my files. however when I follow it up with:
bucket=s3.Bucket('mybuck')
client = boto3.client('s3')
s3file=s3fs.S3FileSystem(anon=False)
fps=s3file.glob('s3://mybuck/2023Apr18/*')
the list "fps" is empty.
In case it matters, the script that I'm doing this in is the entry point for an estimator that I call from another script. The code was working fine before I moved it into this entry point and put it under if __name__==__main__: