futurehouse-client 0.3.17.dev94__py3-none-any.whl → 0.3.18.dev25__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.
@@ -917,14 +917,14 @@ class RestClient:
917
917
  self,
918
918
  job_name: str,
919
919
  file_path: str | os.PathLike,
920
- folder_name: str | None = None,
920
+ upload_id: str | None = None,
921
921
  ) -> str:
922
922
  """Upload a file or directory to a futurehouse job bucket.
923
923
 
924
924
  Args:
925
925
  job_name: The name of the futurehouse job to upload to.
926
926
  file_path: The local path to the file or directory to upload.
927
- folder_name: Optional folder name to use for the upload. If not provided, a random UUID will be used.
927
+ upload_id: Optional folder name to use for the upload. If not provided, a random UUID will be used.
928
928
 
929
929
  Returns:
930
930
  The upload ID used for the upload.
@@ -936,7 +936,7 @@ class RestClient:
936
936
  if not file_path.exists():
937
937
  raise FileNotFoundError(f"File or directory not found: {file_path}")
938
938
 
939
- upload_id = folder_name or str(uuid.uuid4())
939
+ upload_id = upload_id or str(uuid.uuid4())
940
940
 
941
941
  if file_path.is_dir():
942
942
  # Process directory recursively
@@ -1056,12 +1056,18 @@ class RestClient:
1056
1056
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
1057
1057
  retry=retry_if_connection_error,
1058
1058
  )
1059
- def list_files(self, job_name: str, folder_name: str) -> dict[str, list[str]]:
1059
+ def list_files(
1060
+ self,
1061
+ job_name: str,
1062
+ trajectory_id: str | None = None,
1063
+ upload_id: str | None = None,
1064
+ ) -> dict[str, list[str]]:
1060
1065
  """List files and directories in a GCS location for a given job_name and upload_id.
1061
1066
 
1062
1067
  Args:
1063
1068
  job_name: The name of the futurehouse job.
1064
- folder_name: The specific folder name (upload_id) to list files from.
1069
+ trajectory_id: The specific trajectory id to list files from.
1070
+ upload_id: The specific upload id to list files from.
1065
1071
 
1066
1072
  Returns:
1067
1073
  A list of files in the GCS folder.
@@ -1069,22 +1075,27 @@ class RestClient:
1069
1075
  Raises:
1070
1076
  RestClientError: If there is an error listing the files.
1071
1077
  """
1078
+ if not bool(trajectory_id) ^ bool(upload_id):
1079
+ raise RestClientError(
1080
+ "Must at least specify one of trajectory_id or upload_id, but not both"
1081
+ )
1072
1082
  try:
1073
1083
  url = f"/v0.1/crows/{job_name}/list-files"
1074
- params = {"upload_id": folder_name}
1084
+ params = {"trajectory_id": trajectory_id, "upload_id": upload_id}
1085
+ params = {k: v for k, v in params.items() if v is not None}
1075
1086
  response = self.client.get(url, params=params)
1076
1087
  response.raise_for_status()
1077
1088
  return response.json()
1078
1089
  except HTTPStatusError as e:
1079
1090
  logger.exception(
1080
- f"Error listing files for job {job_name}, folder {folder_name}: {e.response.text}"
1091
+ f"Error listing files for job {job_name}, trajectory {trajectory_id}, upload_id {upload_id}: {e.response.text}"
1081
1092
  )
1082
1093
  raise RestClientError(
1083
1094
  f"Error listing files: {e.response.status_code} - {e.response.text}"
1084
1095
  ) from e
1085
1096
  except Exception as e:
1086
1097
  logger.exception(
1087
- f"Error listing files for job {job_name}, folder {folder_name}"
1098
+ f"Error listing files for job {job_name}, trajectory {trajectory_id}, upload_id {upload_id}"
1088
1099
  )
1089
1100
  raise RestClientError(f"Error listing files: {e!s}") from e
1090
1101
 
@@ -1096,7 +1107,7 @@ class RestClient:
1096
1107
  def download_file(
1097
1108
  self,
1098
1109
  job_name: str,
1099
- folder_name: str,
1110
+ trajectory_id: str,
1100
1111
  file_path: str,
1101
1112
  destination_path: str | os.PathLike,
1102
1113
  ) -> None:
@@ -1104,7 +1115,7 @@ class RestClient:
1104
1115
 
1105
1116
  Args:
1106
1117
  job_name: The name of the futurehouse job.
1107
- folder_name: The specific folder name (upload_id) the file belongs to.
1118
+ trajectory_id: The specific trajectory id the file belongs to.
1108
1119
  file_path: The relative path of the file to download
1109
1120
  (e.g., 'data/my_file.csv' or 'my_image.png').
1110
1121
  destination_path: The local path where the file should be saved.
@@ -1119,7 +1130,7 @@ class RestClient:
1119
1130
 
1120
1131
  try:
1121
1132
  url = f"/v0.1/crows/{job_name}/download-file"
1122
- params = {"upload_id": folder_name, "file_path": file_path}
1133
+ params = {"trajectory_id": trajectory_id, "file_path": file_path}
1123
1134
 
1124
1135
  with self.client.stream("GET", url, params=params) as response:
1125
1136
  response.raise_for_status() # Check for HTTP errors before streaming
@@ -1129,7 +1140,7 @@ class RestClient:
1129
1140
  logger.info(f"File {file_path} downloaded to {destination_path}")
1130
1141
  except HTTPStatusError as e:
1131
1142
  logger.exception(
1132
- f"Error downloading file {file_path} for job {job_name}, folder {folder_name}: {e.response.text}"
1143
+ f"Error downloading file {file_path} for job {job_name}, trajectory_id {trajectory_id}: {e.response.text}"
1133
1144
  )
1134
1145
  # Clean up partially downloaded file if an error occurs
1135
1146
  if destination_path.exists():
@@ -1137,9 +1148,20 @@ class RestClient:
1137
1148
  raise RestClientError(
1138
1149
  f"Error downloading file: {e.response.status_code} - {e.response.text}"
1139
1150
  ) from e
1151
+ except RemoteProtocolError as e:
1152
+ logger.error(
1153
+ f"Connection error while downloading file {file_path} for job {job_name}, trajectory_id {trajectory_id}"
1154
+ )
1155
+ # Clean up partially downloaded file
1156
+ if destination_path.exists():
1157
+ destination_path.unlink()
1158
+
1159
+ # Often RemoteProtocolError during download means the file wasn't found
1160
+ # or was empty/corrupted on the server side
1161
+ raise FileNotFoundError(f"File not found or corrupted: {file_path}") from e
1140
1162
  except Exception as e:
1141
1163
  logger.exception(
1142
- f"Error downloading file {file_path} for job {job_name}, folder {folder_name}"
1164
+ f"Error downloading file {file_path} for job {job_name}, trajectory_id {trajectory_id}"
1143
1165
  )
1144
1166
  if destination_path.exists():
1145
1167
  destination_path.unlink() # Clean up partial file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.3.17.dev94
3
+ Version: 0.3.18.dev25
4
4
  Summary: A client for interacting with endpoints of the FutureHouse service.
5
5
  Author-email: FutureHouse technical staff <hello@futurehouse.org>
6
6
  Classifier: Operating System :: OS Independent
@@ -1,7 +1,7 @@
1
1
  futurehouse_client/__init__.py,sha256=ddxO7JE97c6bt7LjNglZZ2Ql8bYCGI9laSFeh9MP6VU,344
2
2
  futurehouse_client/clients/__init__.py,sha256=tFWqwIAY5PvwfOVsCje4imjTpf6xXNRMh_UHIKVI1_0,320
3
3
  futurehouse_client/clients/job_client.py,sha256=Fi3YvN4k82AuXCe8vlwxhkK8CXS164NQrs7paj9qIek,11096
4
- futurehouse_client/clients/rest_client.py,sha256=dsUmpgV5sfyb4GDv6whWVwRN1z2LOfZsPF8vjoioNfY,45472
4
+ futurehouse_client/clients/rest_client.py,sha256=d1D87Uz6bJ-VgXSOHbt6XphXOH0pbe6scW9wcih7uxI,46542
5
5
  futurehouse_client/models/__init__.py,sha256=ta3jFLM_LsDz1rKDmx8rja8sT7WtSKoFvMgLF0yFpvA,342
6
6
  futurehouse_client/models/app.py,sha256=yfZ9tyw4VATVAfYrU7aTdCNPSljLEho09_nIbh8oZDY,23174
7
7
  futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
@@ -10,7 +10,7 @@ futurehouse_client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
10
10
  futurehouse_client/utils/general.py,sha256=A_rtTiYW30ELGEZlWCIArO7q1nEmqi8hUlmBRYkMQ_c,767
11
11
  futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
12
12
  futurehouse_client/utils/monitoring.py,sha256=UjRlufe67kI3VxRHOd5fLtJmlCbVA2Wqwpd4uZhXkQM,8728
13
- futurehouse_client-0.3.17.dev94.dist-info/METADATA,sha256=acLPon9oE1ecVZzz8JrpumcSLmhRkqGGG62gjGEW1IQ,12766
14
- futurehouse_client-0.3.17.dev94.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
15
- futurehouse_client-0.3.17.dev94.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
16
- futurehouse_client-0.3.17.dev94.dist-info/RECORD,,
13
+ futurehouse_client-0.3.18.dev25.dist-info/METADATA,sha256=jTqBZCR7ekzDc5vHGk0y114k_TheT4tcHbxRT7amY7U,12766
14
+ futurehouse_client-0.3.18.dev25.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
15
+ futurehouse_client-0.3.18.dev25.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
16
+ futurehouse_client-0.3.18.dev25.dist-info/RECORD,,