futurehouse-client 0.4.5.dev160__tar.gz → 0.5.0__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 (40) hide show
  1. {futurehouse_client-0.4.5.dev160/src/futurehouse_client.egg-info → futurehouse_client-0.5.0}/PKG-INFO +1 -1
  2. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/clients/data_storage_methods.py +22 -4
  3. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/clients/rest_client.py +2 -2
  4. futurehouse_client-0.5.0/src/futurehouse_client/models/client.py +128 -0
  5. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/version.py +3 -3
  6. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0/src/futurehouse_client.egg-info}/PKG-INFO +1 -1
  7. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/tests/test_data_storage_e2e.py +2 -0
  8. futurehouse_client-0.4.5.dev160/src/futurehouse_client/models/client.py +0 -72
  9. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/LICENSE +0 -0
  10. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/README.md +0 -0
  11. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/data_storage.md +0 -0
  12. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/docs/__init__.py +0 -0
  13. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/docs/client_notebook.ipynb +0 -0
  14. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/pyproject.toml +0 -0
  15. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/setup.cfg +0 -0
  16. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/__init__.py +0 -0
  17. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/clients/__init__.py +0 -0
  18. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/clients/job_client.py +0 -0
  19. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/models/__init__.py +0 -0
  20. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/models/app.py +0 -0
  21. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/models/data_storage_methods.py +0 -0
  22. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/models/job_event.py +0 -0
  23. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/models/rest.py +0 -0
  24. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/py.typed +0 -0
  25. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/utils/__init__.py +0 -0
  26. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/utils/auth.py +0 -0
  27. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/utils/general.py +0 -0
  28. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/utils/module_utils.py +0 -0
  29. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/utils/monitoring.py +0 -0
  30. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client/utils/world_model_tools.py +0 -0
  31. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client.egg-info/SOURCES.txt +0 -0
  32. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client.egg-info/dependency_links.txt +0 -0
  33. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client.egg-info/requires.txt +0 -0
  34. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/src/futurehouse_client.egg-info/top_level.txt +0 -0
  35. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/tests/test_client.py +0 -0
  36. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/tests/test_data/test_file.txt +0 -0
  37. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/tests/test_data/test_information.txt +0 -0
  38. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/tests/test_data/test_manifest.yaml +0 -0
  39. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/tests/test_data_storage_methods.py +0 -0
  40. {futurehouse_client-0.4.5.dev160 → futurehouse_client-0.5.0}/tests/test_rest.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.4.5.dev160
3
+ Version: 0.5.0
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
  License: Apache License
@@ -2492,7 +2492,11 @@ class DataStorageMethods:
2492
2492
  return [
2493
2493
  self._download_from_gcs(
2494
2494
  location.storage_config.signed_url or "",
2495
- (location.storage_config.location or "").split("/")[-1],
2495
+ (
2496
+ Path(location.storage_config.location).name
2497
+ if location.storage_config.location
2498
+ else None
2499
+ ),
2496
2500
  )
2497
2501
  for location in result.storage_locations
2498
2502
  ]
@@ -2508,7 +2512,12 @@ class DataStorageMethods:
2508
2512
  )
2509
2513
 
2510
2514
  return self._download_from_gcs(
2511
- storage_location.storage_config.signed_url
2515
+ storage_location.storage_config.signed_url,
2516
+ (
2517
+ storage_location.storage_config.location.split("/")[-1]
2518
+ if storage_location.storage_config.location
2519
+ else None
2520
+ ),
2512
2521
  )
2513
2522
 
2514
2523
  if storage_type in {"raw_content", "pg_table"}:
@@ -2568,7 +2577,11 @@ class DataStorageMethods:
2568
2577
  [
2569
2578
  self._adownload_from_gcs(
2570
2579
  location.storage_config.signed_url or "",
2571
- (location.storage_config.location or "").split("/")[-1],
2580
+ (
2581
+ location.storage_config.location.split("/")[-1]
2582
+ if location.storage_config.location
2583
+ else None
2584
+ ),
2572
2585
  )
2573
2586
  for location in result.storage_locations
2574
2587
  ],
@@ -2585,7 +2598,12 @@ class DataStorageMethods:
2585
2598
  )
2586
2599
 
2587
2600
  return await self._adownload_from_gcs(
2588
- storage_location.storage_config.signed_url
2601
+ storage_location.storage_config.signed_url,
2602
+ (
2603
+ storage_location.storage_config.location.split("/")[-1]
2604
+ if storage_location.storage_config.location
2605
+ else None
2606
+ ),
2589
2607
  )
2590
2608
 
2591
2609
  if storage_type in {"raw_content", "pg_table"}:
@@ -676,7 +676,7 @@ class RestClient(DataStorageMethods):
676
676
  )
677
677
 
678
678
  response = self.client.post(
679
- "/v0.1/crows", json=task_data.model_dump(mode="json")
679
+ "/v0.1/crows", json=task_data.model_dump(mode="json", by_alias=True)
680
680
  )
681
681
  if response.status_code in {401, 403}:
682
682
  raise PermissionError(
@@ -712,7 +712,7 @@ class RestClient(DataStorageMethods):
712
712
  )
713
713
 
714
714
  response = await self.async_client.post(
715
- "/v0.1/crows", json=task_data.model_dump(mode="json")
715
+ "/v0.1/crows", json=task_data.model_dump(mode="json", by_alias=True)
716
716
  )
717
717
  if response.status_code in {401, 403}:
718
718
  raise PermissionError(
@@ -0,0 +1,128 @@
1
+ from typing import Any, Generic, TypeAlias, TypeVar
2
+
3
+ from aviary.message import Message
4
+ from aviary.tools.base import Tool
5
+ from ldp.agent import Agent
6
+ from ldp.data_structures import Transition
7
+ from ldp.graph.ops import OpResult
8
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
9
+
10
+ from .app import Step
11
+
12
+ T = TypeVar("T")
13
+
14
+
15
+ # TODO: revisit this
16
+ # unsure what crow states will return
17
+ # need to revisit after we get more crows deployed
18
+ class BaseState(BaseModel):
19
+ model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")
20
+
21
+
22
+ class BeforeTransitionState(BaseState):
23
+ current_state: Any = Field()
24
+ observations: list[Message] = Field()
25
+
26
+
27
+ class InitialState(BaseState):
28
+ initial_state: Any = Field()
29
+
30
+
31
+ class ASVState(BaseState, Generic[T]):
32
+ action: OpResult[T] = Field()
33
+ next_state: Any = Field()
34
+ value: float = Field()
35
+
36
+ @field_serializer("action")
37
+ def serialize_action(self, action: OpResult[T]) -> dict:
38
+ return action.to_dict()
39
+
40
+
41
+ class EnvResetState(BaseState):
42
+ observations: list[Message] = Field()
43
+ tools: list[Tool] = Field()
44
+
45
+
46
+ class EnvStepState(BaseState):
47
+ observations: list[Message] = Field()
48
+ reward: float = Field()
49
+ done: bool = Field()
50
+ trunc: bool = Field()
51
+
52
+
53
+ class TransitionState(BaseState):
54
+ transition: Transition = Field()
55
+
56
+ @field_serializer("transition")
57
+ def serialize_transition(self, transition: Transition) -> dict:
58
+ transition_data = transition.model_dump()
59
+ return transition_data | {
60
+ "action": transition.action.to_dict() if transition.action else None,
61
+ }
62
+
63
+
64
+ class GlobalState(BaseState):
65
+ agent: Agent | None = None
66
+ env: Any | None = None
67
+ agent_state: Any | None = None
68
+ next_agent_state: Any | None = None
69
+ observations: list = []
70
+ action: Any | None = None
71
+ value: float = 0.0
72
+ last_step_state: Transition | None = None
73
+
74
+ def update_observations(self, obs: list[Message]) -> list[Message]:
75
+ previous_observations = self.observations or []
76
+ self.observations = obs
77
+ return previous_observations
78
+
79
+ def store_step_state(self, step_state: Transition) -> None:
80
+ self.last_step_state = step_state
81
+
82
+ def update_trajectory_data(self, **kwargs) -> None:
83
+ for key, value in kwargs.items():
84
+ setattr(self, key, value)
85
+
86
+ def _get_safe_previous_observations(
87
+ self, current_obs: list[Message] | None = None
88
+ ) -> list[Message]:
89
+ if self.last_step_state and self.last_step_state.next_observation:
90
+ return self.last_step_state.next_observation
91
+ if self.observations:
92
+ return self.observations
93
+ return current_obs or []
94
+
95
+ def create_step_state(self, callback_type: Step, **kwargs) -> Transition:
96
+ defaults = {
97
+ "timestep": getattr(self.agent, "_timestep", 0) if self.agent else 0,
98
+ "agent_state": self.agent_state,
99
+ "next_agent_state": self.next_agent_state or self.agent_state,
100
+ "observation": self._get_safe_previous_observations(),
101
+ "next_observation": self.observations or [],
102
+ "action": self.action,
103
+ "reward": 0.0,
104
+ "truncated": False,
105
+ "done": False,
106
+ "value": self.value or 0.0,
107
+ "metadata": {"callback_type": callback_type},
108
+ }
109
+
110
+ for key, value in kwargs.items():
111
+ if key == "metadata" and isinstance(value, dict):
112
+ if isinstance(defaults["metadata"], dict):
113
+ defaults["metadata"].update(value)
114
+ else:
115
+ defaults[key] = value
116
+
117
+ return Transition(**defaults)
118
+
119
+
120
+ StateType: TypeAlias = (
121
+ BeforeTransitionState
122
+ | InitialState
123
+ | ASVState
124
+ | EnvResetState
125
+ | EnvStepState
126
+ | TransitionState
127
+ | GlobalState
128
+ )
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.4.5.dev160'
32
- __version_tuple__ = version_tuple = (0, 4, 5, 'dev160')
31
+ __version__ = version = '0.5.0'
32
+ __version_tuple__ = version_tuple = (0, 5, 0)
33
33
 
34
- __commit_id__ = commit_id = 'g7b8da3bce'
34
+ __commit_id__ = commit_id = 'gdcf18bc98'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.4.5.dev160
3
+ Version: 0.5.0
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
  License: Apache License
@@ -282,6 +282,7 @@ async def test_register_existing_content_gcs_async_single(admin_client: RestClie
282
282
 
283
283
  assert isinstance(fetch_response, Path)
284
284
  assert fetch_response.exists()
285
+ assert fetch_response.name == "PMC10054724.tar.gz"
285
286
 
286
287
 
287
288
  @pytest.mark.timeout(300)
@@ -306,6 +307,7 @@ def test_register_existing_content_gcs_sync_single(admin_client: RestClient):
306
307
 
307
308
  assert isinstance(fetch_response, Path)
308
309
  assert fetch_response.exists()
310
+ assert fetch_response.name == "PMC10054724.tar.gz"
309
311
 
310
312
 
311
313
  @pytest.mark.timeout(300)
@@ -1,72 +0,0 @@
1
- from typing import Any, Generic, TypeAlias, TypeVar
2
-
3
- from aviary.message import Message
4
- from aviary.tools.base import Tool
5
- from ldp.data_structures import Transition
6
- from ldp.graph.ops import OpResult
7
- from pydantic import BaseModel, ConfigDict, Field, field_serializer
8
-
9
- T = TypeVar("T")
10
-
11
-
12
- # TODO: revisit this
13
- # unsure what crow states will return
14
- # need to revisit after we get more crows deployed
15
- class BaseState(BaseModel):
16
- model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")
17
-
18
-
19
- class BeforeTransitionState(BaseState):
20
- current_state: Any = Field()
21
- observations: list[Message] = Field()
22
-
23
-
24
- class InitialState(BaseState):
25
- initial_state: Any = Field()
26
-
27
-
28
- class ASVState(BaseState, Generic[T]):
29
- action: OpResult[T] = Field()
30
- next_state: Any = Field()
31
- value: float = Field()
32
-
33
- @field_serializer("action")
34
- def serialize_action(self, action: OpResult[T]) -> dict:
35
- return action.to_dict()
36
-
37
- @field_serializer("next_state")
38
- def serialize_next_state(self, state: Any) -> str:
39
- return str(state)
40
-
41
-
42
- class EnvResetState(BaseState):
43
- observations: list[Message] = Field()
44
- tools: list[Tool] = Field()
45
-
46
-
47
- class EnvStepState(BaseState):
48
- observations: list[Message] = Field()
49
- reward: float = Field()
50
- done: bool = Field()
51
- trunc: bool = Field()
52
-
53
-
54
- class TransitionState(BaseState):
55
- transition: Transition = Field()
56
-
57
- @field_serializer("transition")
58
- def serialize_transition(self, transition: Transition) -> dict:
59
- transition_data = transition.model_dump()
60
- return transition_data | {
61
- "action": transition.action.to_dict() if transition.action else None,
62
- }
63
-
64
-
65
- StateType: TypeAlias = (
66
- BeforeTransitionState
67
- | InitialState
68
- | ASVState
69
- | EnvResetState
70
- | EnvStepState
71
- | TransitionState
72
- )