futurehouse-client 0.3.19.dev111__py3-none-any.whl → 0.3.19.dev129__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.
@@ -444,37 +444,36 @@ class RestClient:
444
444
  self, task_id: str | None = None, history: bool = False, verbose: bool = False
445
445
  ) -> "TaskResponse":
446
446
  """Get details for a specific task."""
447
- try:
448
- task_id = task_id or self.trajectory_id
449
- url = f"/v0.1/trajectories/{task_id}"
450
- full_url = f"{self.base_url}{url}"
451
-
452
- with (
453
- external_trace(
454
- url=full_url,
455
- method="GET",
456
- library="httpx",
457
- custom_params={
458
- "operation": "get_job",
459
- "job_id": task_id,
460
- },
461
- ),
462
- self.client.stream("GET", url, params={"history": history}) as response,
463
- ):
464
- response.raise_for_status()
465
- json_data = "".join(response.iter_text(chunk_size=1024))
466
- data = json.loads(json_data)
467
- if "id" not in data:
468
- data["id"] = task_id
469
- verbose_response = TaskResponseVerbose(**data)
447
+ task_id = task_id or self.trajectory_id
448
+ url = f"/v0.1/trajectories/{task_id}"
449
+ full_url = f"{self.base_url}{url}"
470
450
 
471
- if verbose:
472
- return verbose_response
473
- return JobNames.get_response_object_from_job(verbose_response.job_name)(
474
- **data
475
- )
476
- except Exception as e:
477
- raise TaskFetchError(f"Error getting task: {e!s}") from e
451
+ with (
452
+ external_trace(
453
+ url=full_url,
454
+ method="GET",
455
+ library="httpx",
456
+ custom_params={
457
+ "operation": "get_job",
458
+ "job_id": task_id,
459
+ },
460
+ ),
461
+ self.client.stream("GET", url, params={"history": history}) as response,
462
+ ):
463
+ if response.status_code in {401, 403}:
464
+ raise PermissionError(
465
+ f"Error getting task: Permission denied for task {task_id}"
466
+ )
467
+ response.raise_for_status()
468
+ json_data = "".join(response.iter_text(chunk_size=1024))
469
+ data = json.loads(json_data)
470
+ if "id" not in data:
471
+ data["id"] = task_id
472
+ verbose_response = TaskResponseVerbose(**data)
473
+
474
+ if verbose:
475
+ return verbose_response
476
+ return JobNames.get_response_object_from_job(verbose_response.job_name)(**data)
478
477
 
479
478
  @retry(
480
479
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
@@ -485,39 +484,36 @@ class RestClient:
485
484
  self, task_id: str | None = None, history: bool = False, verbose: bool = False
486
485
  ) -> "TaskResponse":
487
486
  """Get details for a specific task asynchronously."""
488
- try:
489
- task_id = task_id or self.trajectory_id
490
- url = f"/v0.1/trajectories/{task_id}"
491
- full_url = f"{self.base_url}{url}"
487
+ task_id = task_id or self.trajectory_id
488
+ url = f"/v0.1/trajectories/{task_id}"
489
+ full_url = f"{self.base_url}{url}"
490
+
491
+ with external_trace(
492
+ url=full_url,
493
+ method="GET",
494
+ library="httpx",
495
+ custom_params={
496
+ "operation": "get_job",
497
+ "job_id": task_id,
498
+ },
499
+ ):
500
+ async with self.async_client.stream(
501
+ "GET", url, params={"history": history}
502
+ ) as response:
503
+ if response.status_code in {401, 403}:
504
+ raise PermissionError(
505
+ f"Error getting task: Permission denied for task {task_id}"
506
+ )
507
+ response.raise_for_status()
508
+ json_data = "".join([chunk async for chunk in response.aiter_text()])
509
+ data = json.loads(json_data)
510
+ if "id" not in data:
511
+ data["id"] = task_id
512
+ verbose_response = TaskResponseVerbose(**data)
492
513
 
493
- with external_trace(
494
- url=full_url,
495
- method="GET",
496
- library="httpx",
497
- custom_params={
498
- "operation": "get_job",
499
- "job_id": task_id,
500
- },
501
- ):
502
- async with self.async_client.stream(
503
- "GET", url, params={"history": history}
504
- ) as response:
505
- response.raise_for_status()
506
- json_data = "".join([
507
- chunk async for chunk in response.aiter_text()
508
- ])
509
- data = json.loads(json_data)
510
- if "id" not in data:
511
- data["id"] = task_id
512
- verbose_response = TaskResponseVerbose(**data)
513
-
514
- if verbose:
515
- return verbose_response
516
- return JobNames.get_response_object_from_job(verbose_response.job_name)(
517
- **data
518
- )
519
- except Exception as e:
520
- raise TaskFetchError(f"Error getting task: {e!s}") from e
514
+ if verbose:
515
+ return verbose_response
516
+ return JobNames.get_response_object_from_job(verbose_response.job_name)(**data)
521
517
 
522
518
  @retry(
523
519
  stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),
@@ -535,15 +531,16 @@ class RestClient:
535
531
  self.stage,
536
532
  )
537
533
 
538
- try:
539
- response = self.client.post(
540
- "/v0.1/crows", json=task_data.model_dump(mode="json")
534
+ response = self.client.post(
535
+ "/v0.1/crows", json=task_data.model_dump(mode="json")
536
+ )
537
+ if response.status_code in {401, 403}:
538
+ raise PermissionError(
539
+ f"Error creating task: Permission denied for task {task_data.name}"
541
540
  )
542
- response.raise_for_status()
543
- trajectory_id = response.json()["trajectory_id"]
544
- self.trajectory_id = trajectory_id
545
- except Exception as e:
546
- raise TaskFetchError(f"Error creating task: {e!s}") from e
541
+ response.raise_for_status()
542
+ trajectory_id = response.json()["trajectory_id"]
543
+ self.trajectory_id = trajectory_id
547
544
  return trajectory_id
548
545
 
549
546
  @retry(
@@ -561,16 +558,16 @@ class RestClient:
561
558
  task_data.name.name,
562
559
  self.stage,
563
560
  )
564
-
565
- try:
566
- response = await self.async_client.post(
567
- "/v0.1/crows", json=task_data.model_dump(mode="json")
561
+ response = await self.async_client.post(
562
+ "/v0.1/crows", json=task_data.model_dump(mode="json")
563
+ )
564
+ if response.status_code in {401, 403}:
565
+ raise PermissionError(
566
+ f"Error creating task: Permission denied for task {task_data.name}"
568
567
  )
569
- response.raise_for_status()
570
- trajectory_id = response.json()["trajectory_id"]
571
- self.trajectory_id = trajectory_id
572
- except Exception as e:
573
- raise TaskFetchError(f"Error creating task: {e!s}") from e
568
+ response.raise_for_status()
569
+ trajectory_id = response.json()["trajectory_id"]
570
+ self.trajectory_id = trajectory_id
574
571
  return trajectory_id
575
572
 
576
573
  async def arun_tasks_until_done(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.3.19.dev111
3
+ Version: 0.3.19.dev129
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=OzGDkVm5UTUzd4n8yOmRjMF73YrK0FaIQX5gS3Dk8Zo,304
2
2
  futurehouse_client/clients/__init__.py,sha256=-HXNj-XJ3LRO5XM6MZ709iPs29YpApss0Q2YYg1qMZw,280
3
3
  futurehouse_client/clients/job_client.py,sha256=JgB5IUAyCmnhGRsYc3bgKldA-lkM1JLwHRwwUeOCdus,11944
4
- futurehouse_client/clients/rest_client.py,sha256=_XgkzA9OhUKjL9vpkU6ixh2lUW9StgqfGgLk2qHjGgI,55518
4
+ futurehouse_client/clients/rest_client.py,sha256=CiHUYJFZrfRr5mrkt41hxJMesZ2zkCBxqOFJb0t0LGo,55465
5
5
  futurehouse_client/models/__init__.py,sha256=5x-f9AoM1hGzJBEHcHAXSt7tPeImST5oZLuMdwp0mXc,554
6
6
  futurehouse_client/models/app.py,sha256=VCtg0ygd-TSrR6DtfljTBt9jnl1eBNal8UXHFdkDg88,28587
7
7
  futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
@@ -11,7 +11,7 @@ futurehouse_client/utils/auth.py,sha256=tgWELjKfg8eWme_qdcRmc8TjQN9DVZuHHaVXZNHL
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.19.dev111.dist-info/METADATA,sha256=N4Msi8W4mMBXFs_-Pl8Ii12RcLRm2eBl9NiIFCy5--E,12767
15
- futurehouse_client-0.3.19.dev111.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- futurehouse_client-0.3.19.dev111.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
17
- futurehouse_client-0.3.19.dev111.dist-info/RECORD,,
14
+ futurehouse_client-0.3.19.dev129.dist-info/METADATA,sha256=Nd9KxyuyzbrgLFESjeo8-DwXkiK2-xtN-rfoyqaX-ys,12767
15
+ futurehouse_client-0.3.19.dev129.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ futurehouse_client-0.3.19.dev129.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
17
+ futurehouse_client-0.3.19.dev129.dist-info/RECORD,,