Skip to content

Commit

Permalink
prepare 0.4.8 (#56)
Browse files Browse the repository at this point in the history
* Fix s3 download for folders (#54)
* fix ssh (#55)
  • Loading branch information
floriankrb authored Nov 18, 2024
1 parent 0b465c7 commit e1de2b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/anemoi/utils/remote/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def copy(self, source, target, **kwargs):
raise NotImplementedError

def get_temporary_target(self, target, pattern):
if pattern is None:
return target
dirname, basename = os.path.split(target)
return pattern.format(dirname=dirname, basename=basename)

Expand Down Expand Up @@ -199,13 +201,13 @@ def __init__(
target = os.path.basename(source)

temporary_target = {
False: "{dirname}/{basename}",
False: None,
True: "{dirname}-downloading/{basename}",
"-tmp/*": "{dirname}-tmp/{basename}",
"*-tmp": "{dirname}/{basename}-tmp",
"tmp-*": "{dirname}/tmp-{basename}",
}.get(temporary_target, temporary_target)
assert isinstance(temporary_target, str), (type(temporary_target), temporary_target)
assert temporary_target is None or isinstance(temporary_target, str), (type(temporary_target), temporary_target)

self.source = source
self.target = target
Expand Down
3 changes: 3 additions & 0 deletions src/anemoi/utils/remote/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def _transfer_file(self, source, target, overwrite, resume, verbosity, threads,
_, _, bucket, key = source.split("/", 3)
s3 = s3_client(bucket)

if key.endswith("/"):
return 0

try:
response = s3.head_object(Bucket=bucket, Key=key)
except s3.exceptions.ClientError as e:
Expand Down
5 changes: 3 additions & 2 deletions src/anemoi/utils/remote/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def _parse_target(self, target):

def get_temporary_target(self, target, pattern):
hostname, path = self._parse_target(target)
dirname, basename = os.path.split(path)
path = pattern.format(dirname=dirname, basename=basename)
if pattern is not None:
dirname, basename = os.path.split(path)
path = pattern.format(dirname=dirname, basename=basename)
return f"ssh://{hostname}:{path}"

def rename_target(self, target, new_target):
Expand Down

0 comments on commit e1de2b0

Please sign in to comment.