futurehouse-client 0.3.18.dev184__tar.gz → 0.3.18.dev186__tar.gz

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.
Files changed (27) hide show
  1. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/PKG-INFO +1 -1
  2. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/clients/rest_client.py +32 -6
  3. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client.egg-info/PKG-INFO +1 -1
  4. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/LICENSE +0 -0
  5. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/README.md +0 -0
  6. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/docs/__init__.py +0 -0
  7. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/docs/client_notebook.ipynb +0 -0
  8. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/__init__.py +0 -0
  9. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/clients/__init__.py +0 -0
  10. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/clients/job_client.py +0 -0
  11. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/models/__init__.py +0 -0
  12. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/models/app.py +0 -0
  13. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/models/client.py +0 -0
  14. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/models/rest.py +0 -0
  15. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/utils/__init__.py +0 -0
  16. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/utils/auth.py +0 -0
  17. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/utils/general.py +0 -0
  18. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/utils/module_utils.py +0 -0
  19. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client/utils/monitoring.py +0 -0
  20. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client.egg-info/SOURCES.txt +0 -0
  21. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client.egg-info/dependency_links.txt +0 -0
  22. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client.egg-info/requires.txt +0 -0
  23. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/futurehouse_client.egg-info/top_level.txt +0 -0
  24. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/pyproject.toml +0 -0
  25. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/setup.cfg +0 -0
  26. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/tests/test_rest.py +0 -0
  27. {futurehouse_client-0.3.18.dev184 → futurehouse_client-0.3.18.dev186}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.3.18.dev184
3
+ Version: 0.3.18.dev186
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
@@ -358,12 +358,12 @@ class RestClient:
358
358
  if not files:
359
359
  raise TaskFetchError(f"No files found in {path}")
360
360
 
361
+ @refresh_token_on_auth_error()
361
362
  @retry(
362
363
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
363
364
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
364
365
  retry=retry_if_connection_error,
365
366
  )
366
- @refresh_token_on_auth_error()
367
367
  def get_task(
368
368
  self, task_id: str | None = None, history: bool = False, verbose: bool = False
369
369
  ) -> "TaskResponse":
@@ -385,6 +385,7 @@ class RestClient:
385
385
  ),
386
386
  self.client.stream("GET", url, params={"history": history}) as response,
387
387
  ):
388
+ response.raise_for_status()
388
389
  json_data = "".join(response.iter_text(chunk_size=1024))
389
390
  data = json.loads(json_data)
390
391
  if "id" not in data:
@@ -411,12 +412,12 @@ class RestClient:
411
412
  except Exception as e:
412
413
  raise TaskFetchError(f"Error getting task: {e!s}") from e
413
414
 
415
+ @refresh_token_on_auth_error()
414
416
  @retry(
415
417
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
416
418
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
417
419
  retry=retry_if_connection_error,
418
420
  )
419
- @refresh_token_on_auth_error()
420
421
  async def aget_task(
421
422
  self, task_id: str | None = None, history: bool = False, verbose: bool = False
422
423
  ) -> "TaskResponse":
@@ -504,12 +505,12 @@ class RestClient:
504
505
  raise TaskFetchError(f"Error creating task: {e!s}") from e
505
506
  return trajectory_id
506
507
 
508
+ @refresh_token_on_auth_error()
507
509
  @retry(
508
510
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
509
511
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
510
512
  retry=retry_if_connection_error,
511
513
  )
512
- @refresh_token_on_auth_error()
513
514
  async def acreate_task(self, task_data: TaskRequest | dict[str, Any]):
514
515
  """Create a new futurehouse task."""
515
516
  if isinstance(task_data, dict):
@@ -682,12 +683,12 @@ class RestClient:
682
683
  for task_id in trajectory_ids
683
684
  ]
684
685
 
686
+ @refresh_token_on_auth_error()
685
687
  @retry(
686
688
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
687
689
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
688
690
  retry=retry_if_connection_error,
689
691
  )
690
- @refresh_token_on_auth_error()
691
692
  def get_build_status(self, build_id: UUID | None = None) -> dict[str, Any]:
692
693
  """Get the status of a build."""
693
694
  try:
@@ -706,12 +707,12 @@ class RestClient:
706
707
  return response.json()
707
708
 
708
709
  # TODO: Refactor later so we don't have to ignore PLR0915
710
+ @refresh_token_on_auth_error()
709
711
  @retry(
710
712
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
711
713
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
712
714
  retry=retry_if_connection_error,
713
715
  )
714
- @refresh_token_on_auth_error()
715
716
  def create_job(self, config: JobDeploymentConfig) -> dict[str, Any]: # noqa: PLR0915
716
717
  """Creates a futurehouse job deployment from the environment and environment files.
717
718
 
@@ -973,6 +974,7 @@ class RestClient:
973
974
  except Exception as e:
974
975
  raise FileUploadError(f"Error uploading directory {dir_path}: {e}") from e
975
976
 
977
+ @refresh_token_on_auth_error()
976
978
  def _upload_single_file(
977
979
  self,
978
980
  job_name: str,
@@ -1046,11 +1048,20 @@ class RestClient:
1046
1048
  )
1047
1049
 
1048
1050
  logger.info(f"Successfully uploaded {file_name}")
1049
-
1051
+ except HTTPStatusError as e:
1052
+ if e.response.status_code in AUTH_ERRORS_TO_RETRY_ON:
1053
+ raise AuthError(
1054
+ e.response.status_code,
1055
+ f"Authentication failed: {e}",
1056
+ request=e.request,
1057
+ response=e.response,
1058
+ ) from e
1059
+ raise
1050
1060
  except Exception as e:
1051
1061
  logger.exception(f"Error uploading file {file_path}")
1052
1062
  raise FileUploadError(f"Error uploading file {file_path}: {e}") from e
1053
1063
 
1064
+ @refresh_token_on_auth_error()
1054
1065
  @retry(
1055
1066
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
1056
1067
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
@@ -1087,6 +1098,13 @@ class RestClient:
1087
1098
  response.raise_for_status()
1088
1099
  return response.json()
1089
1100
  except HTTPStatusError as e:
1101
+ if e.response.status_code in AUTH_ERRORS_TO_RETRY_ON:
1102
+ raise AuthError(
1103
+ e.response.status_code,
1104
+ f"Authentication failed: {e}",
1105
+ request=e.request,
1106
+ response=e.response,
1107
+ ) from e
1090
1108
  logger.exception(
1091
1109
  f"Error listing files for job {job_name}, trajectory {trajectory_id}, upload_id {upload_id}: {e.response.text}"
1092
1110
  )
@@ -1099,6 +1117,7 @@ class RestClient:
1099
1117
  )
1100
1118
  raise RestClientError(f"Error listing files: {e!s}") from e
1101
1119
 
1120
+ @refresh_token_on_auth_error()
1102
1121
  @retry(
1103
1122
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
1104
1123
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
@@ -1146,6 +1165,13 @@ class RestClient:
1146
1165
 
1147
1166
  logger.info(f"File {file_path} downloaded to {destination_path}")
1148
1167
  except HTTPStatusError as e:
1168
+ if e.response.status_code in AUTH_ERRORS_TO_RETRY_ON:
1169
+ raise AuthError(
1170
+ e.response.status_code,
1171
+ f"Authentication failed: {e}",
1172
+ request=e.request,
1173
+ response=e.response,
1174
+ ) from e
1149
1175
  logger.exception(
1150
1176
  f"Error downloading file {file_path} for job {job_name}, trajectory_id {trajectory_id}: {e.response.text}"
1151
1177
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.3.18.dev184
3
+ Version: 0.3.18.dev186
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