Skip to content

Commit

Permalink
Merge pull request #19 from lilab-bcb/remove-boto3
Browse files Browse the repository at this point in the history
Use s3fs for strato exists on AWS folders
  • Loading branch information
yihming authored Mar 21, 2023
2 parents fa81922 + 2e4a1dc commit 524fa2e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
__pycache__/
*.egg-info/
version.py
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ classifiers = [
]

requires-python = '>=3'
dependencies = []
dependencies = [
's3fs',
'importlib_metadata >= 0.7; python_version < "3.8"',
]

[project.optional-dependencies]
aws = ['boto3']
test = ['pytest']

[tool.black]
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

13 changes: 5 additions & 8 deletions strato/backends/_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,14 @@ def stat(self, filename, profile):
is_folder = True if filename[-1] == "/" else False

if is_folder:
import boto3

fn_list = filename[5:].split("/")
bucket = fn_list[0]
folder = "/".join(fn_list[1:]) if len(fn_list) > 1 else ""
session = boto3.Session(profile_name=profile)
resp = session.client("s3").list_objects_v2(
Bucket=bucket,
Prefix=folder,
)
if resp["KeyCount"] == 0:

from s3fs import S3FileSystem

s3 = S3FileSystem(anon=False, profile=profile)
if len(s3.ls(f"s3://{bucket}/{folder}")) == 0:
raise CalledProcessError(
returncode=1,
cmd=["strato command"],
Expand Down

0 comments on commit 524fa2e

Please sign in to comment.