futurehouse-client 0.3.18.dev184__py3-none-any.whl → 0.3.18.dev185__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.
@@ -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":
@@ -411,12 +411,12 @@ class RestClient:
411
411
  except Exception as e:
412
412
  raise TaskFetchError(f"Error getting task: {e!s}") from e
413
413
 
414
+ @refresh_token_on_auth_error()
414
415
  @retry(
415
416
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
416
417
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
417
418
  retry=retry_if_connection_error,
418
419
  )
419
- @refresh_token_on_auth_error()
420
420
  async def aget_task(
421
421
  self, task_id: str | None = None, history: bool = False, verbose: bool = False
422
422
  ) -> "TaskResponse":
@@ -504,12 +504,12 @@ class RestClient:
504
504
  raise TaskFetchError(f"Error creating task: {e!s}") from e
505
505
  return trajectory_id
506
506
 
507
+ @refresh_token_on_auth_error()
507
508
  @retry(
508
509
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
509
510
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
510
511
  retry=retry_if_connection_error,
511
512
  )
512
- @refresh_token_on_auth_error()
513
513
  async def acreate_task(self, task_data: TaskRequest | dict[str, Any]):
514
514
  """Create a new futurehouse task."""
515
515
  if isinstance(task_data, dict):
@@ -682,12 +682,12 @@ class RestClient:
682
682
  for task_id in trajectory_ids
683
683
  ]
684
684
 
685
+ @refresh_token_on_auth_error()
685
686
  @retry(
686
687
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
687
688
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
688
689
  retry=retry_if_connection_error,
689
690
  )
690
- @refresh_token_on_auth_error()
691
691
  def get_build_status(self, build_id: UUID | None = None) -> dict[str, Any]:
692
692
  """Get the status of a build."""
693
693
  try:
@@ -706,12 +706,12 @@ class RestClient:
706
706
  return response.json()
707
707
 
708
708
  # TODO: Refactor later so we don't have to ignore PLR0915
709
+ @refresh_token_on_auth_error()
709
710
  @retry(
710
711
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
711
712
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
712
713
  retry=retry_if_connection_error,
713
714
  )
714
- @refresh_token_on_auth_error()
715
715
  def create_job(self, config: JobDeploymentConfig) -> dict[str, Any]: # noqa: PLR0915
716
716
  """Creates a futurehouse job deployment from the environment and environment files.
717
717
 
@@ -973,6 +973,7 @@ class RestClient:
973
973
  except Exception as e:
974
974
  raise FileUploadError(f"Error uploading directory {dir_path}: {e}") from e
975
975
 
976
+ @refresh_token_on_auth_error()
976
977
  def _upload_single_file(
977
978
  self,
978
979
  job_name: str,
@@ -1046,11 +1047,20 @@ class RestClient:
1046
1047
  )
1047
1048
 
1048
1049
  logger.info(f"Successfully uploaded {file_name}")
1049
-
1050
+ except HTTPStatusError as e:
1051
+ if e.response.status_code in AUTH_ERRORS_TO_RETRY_ON:
1052
+ raise AuthError(
1053
+ e.response.status_code,
1054
+ f"Authentication failed: {e}",
1055
+ request=e.request,
1056
+ response=e.response,
1057
+ ) from e
1058
+ raise
1050
1059
  except Exception as e:
1051
1060
  logger.exception(f"Error uploading file {file_path}")
1052
1061
  raise FileUploadError(f"Error uploading file {file_path}: {e}") from e
1053
1062
 
1063
+ @refresh_token_on_auth_error()
1054
1064
  @retry(
1055
1065
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
1056
1066
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
@@ -1087,6 +1097,13 @@ class RestClient:
1087
1097
  response.raise_for_status()
1088
1098
  return response.json()
1089
1099
  except HTTPStatusError as e:
1100
+ if e.response.status_code in AUTH_ERRORS_TO_RETRY_ON:
1101
+ raise AuthError(
1102
+ e.response.status_code,
1103
+ f"Authentication failed: {e}",
1104
+ request=e.request,
1105
+ response=e.response,
1106
+ ) from e
1090
1107
  logger.exception(
1091
1108
  f"Error listing files for job {job_name}, trajectory {trajectory_id}, upload_id {upload_id}: {e.response.text}"
1092
1109
  )
@@ -1099,6 +1116,7 @@ class RestClient:
1099
1116
  )
1100
1117
  raise RestClientError(f"Error listing files: {e!s}") from e
1101
1118
 
1119
+ @refresh_token_on_auth_error()
1102
1120
  @retry(
1103
1121
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
1104
1122
  wait=wait_exponential(multiplier=RETRY_MULTIPLIER, max=MAX_RETRY_WAIT),
@@ -1146,6 +1164,13 @@ class RestClient:
1146
1164
 
1147
1165
  logger.info(f"File {file_path} downloaded to {destination_path}")
1148
1166
  except HTTPStatusError as e:
1167
+ if e.response.status_code in AUTH_ERRORS_TO_RETRY_ON:
1168
+ raise AuthError(
1169
+ e.response.status_code,
1170
+ f"Authentication failed: {e}",
1171
+ request=e.request,
1172
+ response=e.response,
1173
+ ) from e
1149
1174
  logger.exception(
1150
1175
  f"Error downloading file {file_path} for job {job_name}, trajectory_id {trajectory_id}: {e.response.text}"
1151
1176
  )
@@ -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.dev185
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=uNkqQbeZw7wbA0qDWcIOwOykrosza-jev58paJZ_mbA,11150
4
- futurehouse_client/clients/rest_client.py,sha256=0SN9cNy2QFVUS9U1L1KDf_ncSx2IV7phbGatdbNlY9w,46814
4
+ futurehouse_client/clients/rest_client.py,sha256=5lhE7jC9qq6pIERMJeKxhi0s-JDvUjx2iEZYFrWPQmw,47870
5
5
  futurehouse_client/models/__init__.py,sha256=5x-f9AoM1hGzJBEHcHAXSt7tPeImST5oZLuMdwp0mXc,554
6
6
  futurehouse_client/models/app.py,sha256=w_1e4F0IiC-BKeOLqYkABYo4U-Nka1S-F64S_eHB2KM,26421
7
7
  futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
@@ -11,7 +11,7 @@ futurehouse_client/utils/auth.py,sha256=Lq9mjSGc7iuRP6fmLICCS6KjzLHN6-tJUuhYp0XX
11
11
  futurehouse_client/utils/general.py,sha256=A_rtTiYW30ELGEZlWCIArO7q1nEmqi8hUlmBRYkMQ_c,767
12
12
  futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
13
13
  futurehouse_client/utils/monitoring.py,sha256=UjRlufe67kI3VxRHOd5fLtJmlCbVA2Wqwpd4uZhXkQM,8728
14
- futurehouse_client-0.3.18.dev184.dist-info/METADATA,sha256=ckn5Ucj4fuMFejVZTtAuw3H7gSqj4NUiIpdLzp8W16I,12767
15
- futurehouse_client-0.3.18.dev184.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
16
- futurehouse_client-0.3.18.dev184.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
17
- futurehouse_client-0.3.18.dev184.dist-info/RECORD,,
14
+ futurehouse_client-0.3.18.dev185.dist-info/METADATA,sha256=7hPM-HuORaESFdHfo-tttwG1vmJ7zecr9IYMRBOG1xc,12767
15
+ futurehouse_client-0.3.18.dev185.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
16
+ futurehouse_client-0.3.18.dev185.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
17
+ futurehouse_client-0.3.18.dev185.dist-info/RECORD,,