compose-api-client 0.1.7__tar.gz → 0.1.9__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 (53) hide show
  1. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/PKG-INFO +1 -1
  2. compose_api_client-0.1.9/compose_api_client/api/results/get_simulations_status_batch.py +168 -0
  3. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/job_status.py +5 -0
  4. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/utils/run_simulation_and_wait.py +13 -5
  5. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client.egg-info/PKG-INFO +1 -1
  6. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client.egg-info/SOURCES.txt +1 -0
  7. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/pyproject.toml +3 -1
  8. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/README.md +0 -0
  9. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/__init__.py +0 -0
  10. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/__init__.py +0 -0
  11. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/biosim_api/__init__.py +0 -0
  12. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/biosim_api/check_health_health_get.py +0 -0
  13. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/biosim_api/get_version_version_get.py +0 -0
  14. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/compute/__init__.py +0 -0
  15. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/compute/get_processes_list.py +0 -0
  16. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/compute/get_simulator_list.py +0 -0
  17. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/compute/get_steps_list.py +0 -0
  18. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/curated/__init__.py +0 -0
  19. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/curated/run_copasi.py +0 -0
  20. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/curated/run_tellurium.py +0 -0
  21. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/results/__init__.py +0 -0
  22. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/results/get_simulation_results_file.py +0 -0
  23. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/results/get_simulation_status.py +0 -0
  24. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/results/get_simulator_build_status.py +0 -0
  25. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/simulation/__init__.py +0 -0
  26. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/api/simulation/run_simulation.py +0 -0
  27. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/client.py +0 -0
  28. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/errors.py +0 -0
  29. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/__init__.py +0 -0
  30. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/bi_graph_compute_type.py +0 -0
  31. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/bi_graph_process.py +0 -0
  32. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/bi_graph_step.py +0 -0
  33. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/body_run_copasi.py +0 -0
  34. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/body_run_simulation.py +0 -0
  35. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/body_run_tellurium.py +0 -0
  36. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/check_health_health_get_response_check_health_health_get.py +0 -0
  37. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/containerization_file_repr.py +0 -0
  38. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/hpc_run.py +0 -0
  39. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/http_validation_error.py +0 -0
  40. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/job_type.py +0 -0
  41. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/package_type.py +0 -0
  42. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/registered_package.py +0 -0
  43. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/registered_simulators.py +0 -0
  44. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/simulation_experiment.py +0 -0
  45. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/simulation_experiment_metadata.py +0 -0
  46. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/simulator_version.py +0 -0
  47. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/models/validation_error.py +0 -0
  48. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/types.py +0 -0
  49. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client/utils/__init__.py +0 -0
  50. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client.egg-info/dependency_links.txt +0 -0
  51. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client.egg-info/requires.txt +0 -0
  52. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/compose_api_client.egg-info/top_level.txt +0 -0
  53. {compose_api_client-0.1.7 → compose_api_client-0.1.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compose-api-client
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,168 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.hpc_run import HpcRun
9
+ from ...models.http_validation_error import HTTPValidationError
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs(
14
+ *,
15
+ body: list[int],
16
+ ) -> dict[str, Any]:
17
+ headers: dict[str, Any] = {}
18
+
19
+ _kwargs: dict[str, Any] = {
20
+ "method": "get",
21
+ "url": "/results/simulations/status/batch",
22
+ }
23
+
24
+ _kwargs["json"] = body
25
+
26
+ headers["Content-Type"] = "application/json"
27
+
28
+ _kwargs["headers"] = headers
29
+ return _kwargs
30
+
31
+
32
+ def _parse_response(
33
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
34
+ ) -> Optional[Union[HTTPValidationError, list["HpcRun"]]]:
35
+ if response.status_code == 200:
36
+ response_200 = []
37
+ _response_200 = response.json()
38
+ for response_200_item_data in _response_200:
39
+ response_200_item = HpcRun.from_dict(response_200_item_data)
40
+
41
+ response_200.append(response_200_item)
42
+
43
+ return response_200
44
+ if response.status_code == 422:
45
+ response_422 = HTTPValidationError.from_dict(response.json())
46
+
47
+ return response_422
48
+ if client.raise_on_unexpected_status:
49
+ raise errors.UnexpectedStatus(response.status_code, response.content)
50
+ else:
51
+ return None
52
+
53
+
54
+ def _build_response(
55
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
56
+ ) -> Response[Union[HTTPValidationError, list["HpcRun"]]]:
57
+ return Response(
58
+ status_code=HTTPStatus(response.status_code),
59
+ content=response.content,
60
+ headers=response.headers,
61
+ parsed=_parse_response(client=client, response=response),
62
+ )
63
+
64
+
65
+ def sync_detailed(
66
+ *,
67
+ client: Union[AuthenticatedClient, Client],
68
+ body: list[int],
69
+ ) -> Response[Union[HTTPValidationError, list["HpcRun"]]]:
70
+ """Get simulation status records for a list of IDs
71
+
72
+ Args:
73
+ body (list[int]):
74
+
75
+ Raises:
76
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
77
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
78
+
79
+ Returns:
80
+ Response[Union[HTTPValidationError, list['HpcRun']]]
81
+ """
82
+
83
+ kwargs = _get_kwargs(
84
+ body=body,
85
+ )
86
+
87
+ response = client.get_httpx_client().request(
88
+ **kwargs,
89
+ )
90
+
91
+ return _build_response(client=client, response=response)
92
+
93
+
94
+ def sync(
95
+ *,
96
+ client: Union[AuthenticatedClient, Client],
97
+ body: list[int],
98
+ ) -> Optional[Union[HTTPValidationError, list["HpcRun"]]]:
99
+ """Get simulation status records for a list of IDs
100
+
101
+ Args:
102
+ body (list[int]):
103
+
104
+ Raises:
105
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
106
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
107
+
108
+ Returns:
109
+ Union[HTTPValidationError, list['HpcRun']]
110
+ """
111
+
112
+ return sync_detailed(
113
+ client=client,
114
+ body=body,
115
+ ).parsed
116
+
117
+
118
+ async def asyncio_detailed(
119
+ *,
120
+ client: Union[AuthenticatedClient, Client],
121
+ body: list[int],
122
+ ) -> Response[Union[HTTPValidationError, list["HpcRun"]]]:
123
+ """Get simulation status records for a list of IDs
124
+
125
+ Args:
126
+ body (list[int]):
127
+
128
+ Raises:
129
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
130
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
131
+
132
+ Returns:
133
+ Response[Union[HTTPValidationError, list['HpcRun']]]
134
+ """
135
+
136
+ kwargs = _get_kwargs(
137
+ body=body,
138
+ )
139
+
140
+ response = await client.get_async_httpx_client().request(**kwargs)
141
+
142
+ return _build_response(client=client, response=response)
143
+
144
+
145
+ async def asyncio(
146
+ *,
147
+ client: Union[AuthenticatedClient, Client],
148
+ body: list[int],
149
+ ) -> Optional[Union[HTTPValidationError, list["HpcRun"]]]:
150
+ """Get simulation status records for a list of IDs
151
+
152
+ Args:
153
+ body (list[int]):
154
+
155
+ Raises:
156
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
157
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
158
+
159
+ Returns:
160
+ Union[HTTPValidationError, list['HpcRun']]
161
+ """
162
+
163
+ return (
164
+ await asyncio_detailed(
165
+ client=client,
166
+ body=body,
167
+ )
168
+ ).parsed
@@ -2,11 +2,16 @@ from enum import Enum
2
2
 
3
3
 
4
4
  class JobStatus(str, Enum):
5
+ CANCELLED = "cancelled"
5
6
  COMPLETED = "completed"
6
7
  FAILED = "failed"
8
+ OUT_OF_MEMORY = "out_of_memory"
7
9
  PENDING = "pending"
8
10
  QUEUED = "queued"
9
11
  RUNNING = "running"
12
+ SUSPENDED = "suspended"
13
+ TIMEOUT = "timeout"
14
+ UNKNOWN = "unknown"
10
15
  WAITING = "waiting"
11
16
 
12
17
  def __str__(self) -> str:
@@ -1,5 +1,5 @@
1
1
  import asyncio
2
- from typing import Any, Tuple
2
+ from typing import Tuple
3
3
 
4
4
  from compose_api_client import Client
5
5
  from compose_api_client.api.results import (
@@ -57,7 +57,9 @@ async def async_call(
57
57
  while current_status is None and num_loops < loops_to_wait:
58
58
  print("Waiting for simulation to be submitted to slurm.")
59
59
  await asyncio.sleep(sleep_interval)
60
- current_status = _get_current_status(client, sim_experiment.simulation_database_id)
60
+ current_status = await _get_current_status(
61
+ client, sim_experiment.simulation_database_id
62
+ )
61
63
  num_loops += 1
62
64
 
63
65
  if current_status is None:
@@ -74,8 +76,14 @@ async def async_call(
74
76
  )
75
77
  num_loops += 1
76
78
 
77
- if current_status.status == JobStatus.FAILED:
78
- raise RuntimeError(f"Simulation failed: {current_status}")
79
+ incomplete_statuses = {
80
+ JobStatus.FAILED,
81
+ JobStatus.CANCELLED,
82
+ JobStatus.TIMEOUT,
83
+ JobStatus.OUT_OF_MEMORY,
84
+ }
85
+ if current_status.status in incomplete_statuses:
86
+ raise RuntimeError(f"Simulation stopped with status: {current_status}")
79
87
 
80
88
  print(
81
89
  f"Waited {num_loops * sleep_interval} seconds for simulation to complete. Current status: {current_status}"
@@ -93,7 +101,7 @@ async def async_call(
93
101
  client=client, simulation_id=sim_experiment.simulation_database_id
94
102
  )
95
103
 
96
- print(f"Simulation has completed.")
104
+ print("Simulation has completed.")
97
105
 
98
106
  if results.status_code != 200:
99
107
  raise RuntimeError(f"Could not get simulation results: {results}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compose-api-client
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -23,6 +23,7 @@ compose_api_client/api/curated/run_tellurium.py
23
23
  compose_api_client/api/results/__init__.py
24
24
  compose_api_client/api/results/get_simulation_results_file.py
25
25
  compose_api_client/api/results/get_simulation_status.py
26
+ compose_api_client/api/results/get_simulations_status_batch.py
26
27
  compose_api_client/api/results/get_simulator_build_status.py
27
28
  compose_api_client/api/simulation/__init__.py
28
29
  compose_api_client/api/simulation/run_simulation.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "compose-api-client"
3
- version = "0.1.7"
3
+ version = "0.1.9"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -14,4 +14,6 @@ dependencies = [
14
14
  dev = [
15
15
  "deptry>=0.23.0,<0.24",
16
16
  "pre-commit>=3.4.0,<4",
17
+ "pytest",
18
+ "pytest-asyncio"
17
19
  ]