hafnia 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import shutil
3
3
  import subprocess
4
+ import sys
4
5
  import tempfile
5
6
  import uuid
6
7
  from pathlib import Path
@@ -91,22 +92,30 @@ def download_dataset_from_access_endpoint(
91
92
  s3_dataset_files = [f"{s3_uri}/{filename}" for filename in DATASET_FILENAMES_REQUIRED]
92
93
 
93
94
  envs = resource_credentials.aws_credentials()
94
- fast_copy_files_s3(
95
- src_paths=s3_dataset_files,
96
- dst_paths=local_dataset_paths,
97
- append_envs=envs,
98
- description="Downloading annotations",
99
- )
95
+ try:
96
+ fast_copy_files_s3(
97
+ src_paths=s3_dataset_files,
98
+ dst_paths=local_dataset_paths,
99
+ append_envs=envs,
100
+ description="Downloading annotations",
101
+ )
102
+ except ValueError as e:
103
+ user_logger.error(f"Failed to download annotations: {e}")
104
+ return
100
105
 
101
106
  if not download_files:
102
107
  return
103
108
  dataset = HafniaDataset.from_path(path_dataset, check_for_images=False)
104
- fast_copy_files_s3(
105
- src_paths=dataset.samples[ColumnName.REMOTE_PATH].to_list(),
106
- dst_paths=dataset.samples[ColumnName.FILE_NAME].to_list(),
107
- append_envs=envs,
108
- description="Downloading images",
109
- )
109
+ try:
110
+ fast_copy_files_s3(
111
+ src_paths=dataset.samples[ColumnName.REMOTE_PATH].to_list(),
112
+ dst_paths=dataset.samples[ColumnName.FILE_NAME].to_list(),
113
+ append_envs=envs,
114
+ description="Downloading images",
115
+ )
116
+ except ValueError as e:
117
+ user_logger.error(f"Failed to download images: {e}")
118
+ return
110
119
 
111
120
 
112
121
  def fast_copy_files_s3(
@@ -117,7 +126,6 @@ def fast_copy_files_s3(
117
126
  ) -> List[str]:
118
127
  if len(src_paths) != len(dst_paths):
119
128
  raise ValueError("Source and destination paths must have the same length.")
120
-
121
129
  cmds = [f"cp {src} {dst}" for src, dst in zip(src_paths, dst_paths)]
122
130
  lines = execute_s5cmd_commands(cmds, append_envs=append_envs, description=description)
123
131
  return lines
@@ -134,11 +142,9 @@ def execute_s5cmd_commands(
134
142
  with tempfile.TemporaryDirectory() as temp_dir:
135
143
  tmp_file_path = Path(temp_dir, f"{uuid.uuid4().hex}.txt")
136
144
  tmp_file_path.write_text("\n".join(commands))
137
- run_cmds = [
138
- "s5cmd",
139
- "run",
140
- str(tmp_file_path),
141
- ]
145
+ s5cmd_bin = (Path(sys.executable).parent / "s5cmd").absolute().as_posix()
146
+ run_cmds = [s5cmd_bin, "run", str(tmp_file_path)]
147
+ sys_logger.debug(run_cmds)
142
148
  envs = os.environ.copy()
143
149
  envs.update(append_envs)
144
150
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hafnia
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Python SDK for communication with Hafnia platform.
5
5
  Author-email: Milestone Systems <hafniaplatform@milestone.dk>
6
6
  License-File: LICENSE
@@ -37,13 +37,13 @@ hafnia/experiment/__init__.py,sha256=OEFE6HqhO5zcTCLZcPcPVjIg7wMFFnvZ1uOtAVhRz7M
37
37
  hafnia/experiment/hafnia_logger.py,sha256=dnV3VPzJK7DSeUh0g4Hk9w1g-eSXcVqJD9If0h2d2GE,6885
38
38
  hafnia/platform/__init__.py,sha256=zJsR6Hy_0iUcC9xL-lBnqR0mLfF4EUr_VXa_XQA7SlA,455
39
39
  hafnia/platform/builder.py,sha256=_g8ykQWETz5Y4Np9QU1a6wIzbbJwXCkbiOCA6JcF5Rc,5742
40
- hafnia/platform/datasets.py,sha256=mRv8A0JSMYdBr3_0qqrw21kKSSPMSYUFWyPVNxYqZrA,7344
40
+ hafnia/platform/datasets.py,sha256=FPDoRDR1aLIqp2paXy7ThE2-1CfwxX8WZr327GPGFnM,7705
41
41
  hafnia/platform/download.py,sha256=oJzdxSIDTuw1an7maC6I7A5nZvDaZPhUkuAmyRwN9Kc,6843
42
42
  hafnia/platform/experiment.py,sha256=-nAfTmn1c8sE6pHDCTNZvWDTopkXndarJAPIGvsnk60,2389
43
43
  hafnia/visualizations/colors.py,sha256=003eAJVnBal4abaYIIpsrT7erIOIjTUHHYVJ1Tj1CDc,5226
44
44
  hafnia/visualizations/image_visualizations.py,sha256=RuFFj2fJCm9dxl2Lq0MumJHF81ZnX-IsDsTxm8ZFV9A,7313
45
- hafnia-0.2.3.dist-info/METADATA,sha256=7ZwSgwrbliqkHYTy11Sg01su1z-aZiWSGs9Y6qHBQ4k,19040
46
- hafnia-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
- hafnia-0.2.3.dist-info/entry_points.txt,sha256=FCJVIQ8GP2VE9I3eeGVF5eLxVDNW_01pOJCpG_CGnMM,45
48
- hafnia-0.2.3.dist-info/licenses/LICENSE,sha256=wLZw1B7_mod_CO1H8LXqQgfqlWD6QceJR8--LJYRZGE,1078
49
- hafnia-0.2.3.dist-info/RECORD,,
45
+ hafnia-0.2.4.dist-info/METADATA,sha256=8sP2loU7KuxgK0FjvAigfs0TWl302a4BOhpwOEelyGs,19040
46
+ hafnia-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
+ hafnia-0.2.4.dist-info/entry_points.txt,sha256=FCJVIQ8GP2VE9I3eeGVF5eLxVDNW_01pOJCpG_CGnMM,45
48
+ hafnia-0.2.4.dist-info/licenses/LICENSE,sha256=wLZw1B7_mod_CO1H8LXqQgfqlWD6QceJR8--LJYRZGE,1078
49
+ hafnia-0.2.4.dist-info/RECORD,,
File without changes