Skip to content

Commit

Permalink
Merge pull request #91 from NOAA-GSL/IDSSE-1054
Browse files Browse the repository at this point in the history
Idsse 1054
  • Loading branch information
paulhamer-noaa authored Jan 2, 2025
2 parents fdfd2b5 + 6066dbd commit 7fa7141
Show file tree
Hide file tree
Showing 4 changed files with 337 additions and 25 deletions.
6 changes: 5 additions & 1 deletion python/idsse_common/idsse/common/aws_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def ls(self, path: str, prepend_path: bool = True) -> Sequence[str]:
return [os.path.join(path, filename.split(' ')[-1]) for filename in commands_result]
return [filename.split(' ')[-1] for filename in commands_result]

def cp(self, path: str, dest: str, concurrency: int | None = None, chunk_size: int | None = None) -> bool:
def cp(self,
path: str,
dest: str,
concurrency: int | None = None,
chunk_size: int | None = None) -> bool:
"""Execute a 'cp' on the AWS s3 bucket specified by path, dest. Attempts to use
[s5cmd](https://github.com/peak/s5cmd) to copy the file from S3 with parallelization,
but falls back to (slower) aws-cli if s5cmd is not installed or throws an error.
Expand Down
6 changes: 5 additions & 1 deletion python/idsse_common/idsse/common/http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def ls(self, path: str, prepend_path: bool = True) -> Sequence[str]:
return files

# pylint: disable=unused-argument
def cp(self, path: str, dest: str, concurrency: int | None = None, chunk_size: int | None = None) -> bool:
def cp(self,
path: str,
dest: str,
concurrency: int | None = None,
chunk_size: int | None = None) -> bool:
"""Execute http request download from path to dest.
Args:
Expand Down
7 changes: 0 additions & 7 deletions python/idsse_common/test/test_http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ def test_ls_without_prepend_path(http_utils: HttpUtils, httpserver: HTTPServer):
assert len(result) == len(EXAMPLE_FILES)
assert result[0] == EXAMPLE_FILES[-1]


def test_ls_on_error(http_utils: HttpUtils, httpserver: HTTPServer):
httpserver.expect_request('/data/'+EXAMPLE_ENDPOINT).respond_with_data('', content_type="text/plain")
result = http_utils.ls(EXAMPLE_URL + EXAMPLE_ENDPOINT)
assert result == []


def test_cp_succeeds(http_utils: HttpUtils, httpserver: HTTPServer):
url = '/data/'+EXAMPLE_PROD_DIR+'/temp.grib2.gz'
httpserver.expect_request(url).respond_with_data(bytes([0,1,2]), status=200,
Expand Down
Loading

0 comments on commit 7fa7141

Please sign in to comment.