codeocean 0.1.4__tar.gz → 0.1.6__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.
@@ -1,9 +1,17 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ ## 0.1.6 (2024-10-15)
5
+
6
+ - [#13](https://github.com/codeocean/codeocean-sdk-python/pull/13) feat: makes polling interval configurable
7
+
8
+ ## 0.1.5 (2024-08-08)
9
+
10
+ - [#10](https://github.com/codeocean/codeocean-sdk-python/pull/10) fix: Provenance optional fields
11
+
4
12
  ## 0.1.4 (2024-08-02)
5
13
 
6
- - Add support for Python >= 3.9
14
+ - Add support for Python >= 3.9
7
15
 
8
16
  ## 0.1.3 (2024-07-09)
9
17
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: codeocean
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Code Ocean Python SDK
5
5
  Project-URL: Homepage, https://github.com/codeocean/codeocean-sdk-python
6
6
  Project-URL: Issues, https://github.com/codeocean/codeocean-sdk-python/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "codeocean"
7
- version = "0.1.4"
7
+ version = "0.1.6"
8
8
  authors = [
9
9
  { name="Code Ocean", email="dev@codeocean.com" },
10
10
  ]
@@ -141,17 +141,21 @@ class Computations:
141
141
 
142
142
  return Computation.from_dict(res.json())
143
143
 
144
- def wait_until_completed(self, computation: Computation) -> Computation:
144
+ def wait_until_completed(self, computation: Computation, polling_interval: int = 5) -> Computation:
145
145
  """
146
146
  Polls the given computation until it reaches the 'Completed' or 'Failed' state.
147
147
  """
148
+ if polling_interval < 5:
149
+ raise ValueError(
150
+ f"Polling interval {polling_interval} should be greater than or equal to 5"
151
+ )
148
152
  while True:
149
153
  comp = self.get_computation(computation.id)
150
154
 
151
155
  if comp.state in [ComputationState.Completed, ComputationState.Failed]:
152
156
  return comp
153
157
 
154
- sleep(5)
158
+ sleep(polling_interval)
155
159
 
156
160
  def list_computation_results(self, computation_id: str, path: str = "") -> Folder:
157
161
  data = {
@@ -27,9 +27,9 @@ class DataAssetState(StrEnum):
27
27
  class Provenance:
28
28
  commit: str
29
29
  run_script: str
30
- data_assets: str
31
30
  docker_image: str
32
31
  capsule: str
32
+ data_assets: Optional[list[str]] = None
33
33
 
34
34
 
35
35
  class DataAssetOrigin(StrEnum):
@@ -237,17 +237,21 @@ class DataAssets:
237
237
 
238
238
  return DataAsset.from_dict(res.json())
239
239
 
240
- def wait_until_ready(self, data_asset: DataAsset) -> DataAsset:
240
+ def wait_until_ready(self, data_asset: DataAsset, polling_interval: int = 5) -> DataAsset:
241
241
  """
242
242
  Polls the given data asset until it reaches the 'Ready' or 'Failed' state.
243
243
  """
244
+ if polling_interval < 5:
245
+ raise ValueError(
246
+ f"Polling interval {polling_interval} should be greater than or equal to 5"
247
+ )
244
248
  while True:
245
249
  da = self.get_data_asset(data_asset.id)
246
250
 
247
251
  if da.state in [DataAssetState.Ready, DataAssetState.Failed]:
248
252
  return da
249
253
 
250
- sleep(5)
254
+ sleep(polling_interval)
251
255
 
252
256
  def delete_data_asset(self, data_asset_id: str):
253
257
  self.client.delete(f"data_assets/{data_asset_id}")
File without changes
File without changes
File without changes
File without changes
File without changes