parallel-web 0.1.0__py3-none-any.whl → 0.1.1__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.

Potentially problematic release.


This version of parallel-web might be problematic. Click here for more details.

parallel/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "parallel"
4
- __version__ = "0.1.0" # x-release-please-version
4
+ __version__ = "0.1.1" # x-release-please-version
parallel/lib/_pydantic.py CHANGED
@@ -10,20 +10,22 @@ from .._compat import PYDANTIC_V2, model_json_schema
10
10
 
11
11
 
12
12
  def to_json_schema(
13
- model: type[pydantic.BaseModel] | pydantic.TypeAdapter[Any],
13
+ model_type: type[pydantic.BaseModel] | pydantic.TypeAdapter[Any],
14
14
  ) -> dict[str, Any]:
15
15
  """Convert a Pydantic model/type adapter to a JSON schema."""
16
- if inspect.isclass(model) and is_basemodel_type(model):
17
- return model_json_schema(model)
18
-
19
- if PYDANTIC_V2 and isinstance(model, pydantic.TypeAdapter):
20
- return model.json_schema()
21
-
22
- raise TypeError(f"Non BaseModel types are only supported with Pydantic v2 - {model}")
23
-
24
-
25
- def is_basemodel_type(typ: type | object) -> TypeGuard[type[pydantic.BaseModel]]:
26
- """Check if a type is a Pydantic BaseModel."""
27
- if not inspect.isclass(typ):
28
- return False
29
- return issubclass(typ, pydantic.BaseModel)
16
+ if is_basemodel_type(model_type):
17
+ schema = model_json_schema(model_type)
18
+ elif isinstance(model_type, pydantic.TypeAdapter):
19
+ if not PYDANTIC_V2:
20
+ raise TypeError(f"TypeAdapters are only supported with Pydantic v2 - {model_type}")
21
+ schema = model_type.json_schema()
22
+ else:
23
+ raise TypeError(f"Unsupported type: {model_type}")
24
+
25
+ # modify the schema to make it compatible with the API format
26
+ schema["additionalProperties"] = False
27
+ return schema
28
+
29
+ def is_basemodel_type(model_type: object) -> TypeGuard[type[pydantic.BaseModel]]:
30
+ """Check if a type is a Pydantic BaseModel to avoid using type: ignore."""
31
+ return inspect.isclass(model_type) and issubclass(model_type, pydantic.BaseModel)
@@ -29,12 +29,9 @@ class TaskRun(BaseModel):
29
29
  is_active: bool
30
30
  """Whether the run is currently active; i.e.
31
31
 
32
- status is one of {'queued', 'running', 'cancelling'}.
32
+ status is one of {'running', 'queued', 'cancelling'}.
33
33
  """
34
34
 
35
- message: Optional[str] = None
36
- """Human-readable status message for the run."""
37
-
38
35
  modified_at: Optional[str] = None
39
36
  """Timestamp of the last modification to the task, as an RFC 3339 string."""
40
37
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: parallel-web
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: The official Python library for the Parallel API
5
5
  Project-URL: Homepage, https://github.com/shapleyai/parallel-sdk-python
6
6
  Project-URL: Repository, https://github.com/shapleyai/parallel-sdk-python
@@ -223,15 +223,15 @@ from parallel.types import TaskSpecParam
223
223
  client = Parallel()
224
224
 
225
225
  task_run = client.task_run.create(
226
- input="France (2023)",
227
- processor="processor",
226
+ input={"country": "France", "year": 2023},
227
+ processor="core",
228
228
  task_spec={
229
229
  "output_schema": {
230
230
  "json_schema": {
231
231
  "additionalProperties": False,
232
232
  "properties": {
233
233
  "gdp": {
234
- "description": "GDP in USD for the year, formatted like '$3.1 trillion (2023)'",
234
+ "description": "GDP in USD for the year",
235
235
  "type": "string",
236
236
  }
237
237
  },
@@ -244,12 +244,16 @@ task_run = client.task_run.create(
244
244
  "json_schema": {
245
245
  "additionalProperties": False,
246
246
  "properties": {
247
- "gdp": {
248
- "description": "GDP in USD for the year, formatted like '$3.1 trillion (2023)'",
247
+ "country": {
248
+ "description": "Name of the country to research",
249
249
  "type": "string",
250
- }
250
+ },
251
+ "year": {
252
+ "description": "Year for which to retrieve information",
253
+ "type": "integer",
254
+ },
251
255
  },
252
- "required": ["gdp"],
256
+ "required": ["country", "year"],
253
257
  "type": "object",
254
258
  },
255
259
  "type": "json",
@@ -257,7 +261,7 @@ task_run = client.task_run.create(
257
261
  },
258
262
  )
259
263
 
260
- run_result = client.task_run.result(task_run.id)
264
+ run_result = client.task_run.result(task_run.run_id)
261
265
  print(run_result.output)
262
266
  ```
263
267
 
@@ -11,7 +11,7 @@ parallel/_resource.py,sha256=QvY8l_r03hNBsFTTn3g7Pkx8OrDwIwROHaSEViWcYLA,1112
11
11
  parallel/_response.py,sha256=zJKnQ9YzrMZCTPWis4CdyGCAH0kzT4m1OHE74jiF0jA,28800
12
12
  parallel/_streaming.py,sha256=vH45vK3-83ruFalbvSgpE70zfwy8fjW9UwrO1TwjIfE,10108
13
13
  parallel/_types.py,sha256=sLRqW7zYEpLbSD4AuQ4UHoZoXMuu1p8hOq8LpwE69-k,6145
14
- parallel/_version.py,sha256=9X4SlrNWQKYPBlIjPqW5KAvoYD3JrSFlMBD_J44IF4E,160
14
+ parallel/_version.py,sha256=GRc9LkIy5Itj2tGLZK_gVSgSD64UnoOEee7OQv1r-gA,160
15
15
  parallel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  parallel/_utils/__init__.py,sha256=Z5F2puD-cRsBEwlAuuuXDuIuKuJyLhtg0667MRHeBj4,2084
17
17
  parallel/_utils/_logs.py,sha256=5tqZJRHHRqxJfftED6vN1CHcwhRZDSvzy9SaxozEAe4,780
@@ -24,7 +24,7 @@ parallel/_utils/_typing.py,sha256=D0DbbNu8GnYQTSICnTSHDGsYXj8TcAKyhejb0XcnjtY,46
24
24
  parallel/_utils/_utils.py,sha256=nJWF6GJgM2imb1AYa1nZoE1f-Alo1EI0Y8L_q3a1gkw,12389
25
25
  parallel/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
26
  parallel/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- parallel/lib/_pydantic.py,sha256=90cesmaaPfF1CmlDVBDzFq4k1qciHTAwnWbHa159FwQ,886
27
+ parallel/lib/_pydantic.py,sha256=B_-msp3_jrPP09s-f73Xv4WEG212ECDfc0a_Gf-YZGE,1115
28
28
  parallel/lib/_time.py,sha256=IoPTaxTh5bYaBqSH7zUSYoKfnfCX5G208xB9_s7BAn4,1726
29
29
  parallel/lib/_parsing/__init__.py,sha256=aEM9F2sU4s-CFpQgjydjfCAdxpusJ81jXI6KCoB8VPs,150
30
30
  parallel/lib/_parsing/_task_run_result.py,sha256=9o95RcH4bX0UbI7ow5bnECrXMS6Ll0SEQR4leTK3VQU,3608
@@ -34,13 +34,13 @@ parallel/resources/task_run.py,sha256=b0A5mh52CbYDJ6QeFJesCEDkeivwdX6E8TV6dsxDXa
34
34
  parallel/types/__init__.py,sha256=7EXEF1xwgzRtPbtywm1_PnOzShi_mN3TfU8p_PErz5s,653
35
35
  parallel/types/json_schema_param.py,sha256=rn_85_uPZYkLYLZiM5erOuQ_trY4DcoB3XEpP4uvqyw,457
36
36
  parallel/types/parsed_task_run_result.py,sha256=Qw_QFQNmMcykdBKlMnx6hl5cua5wwv5BZEs3Oo3_5NE,1098
37
- parallel/types/task_run.py,sha256=kBC1pFRp4w9eTk2WVLE1e7QG85Zn6J_l5aJJoXqZtLU,1462
37
+ parallel/types/task_run.py,sha256=mdkBL1Ncvu5h2HeBSzF2vr7Q-ApOOStsZCeEwFl_uQA,1374
38
38
  parallel/types/task_run_create_params.py,sha256=kHEx3NInuAgTp5AebDHQIPyrqducGFUMV81Gtn7wtdI,957
39
39
  parallel/types/task_run_result.py,sha256=yd3Lz_YzCQGe5ynK5iI6J17tAs5nSG7FUJ3fSLOa7hM,3070
40
40
  parallel/types/task_run_result_params.py,sha256=tL4CK5c0-Wo21O1pmT4pDvwzG-svtEwYujyCp0ZgATs,360
41
41
  parallel/types/task_spec_param.py,sha256=qTENHBp7vRg-VDzK8HsLpTn3EJWIV0UVQaf45r9SfCs,1179
42
42
  parallel/types/text_schema_param.py,sha256=M9WEl2aOh4_hNSdGm2BOmtm1VGqxxTh3f-Hs4OB4aCQ,445
43
- parallel_web-0.1.0.dist-info/METADATA,sha256=H-ohJ34Ju20Os1LD1P6zU872ocIGgyYcYT23EfFlNUs,17361
44
- parallel_web-0.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
45
- parallel_web-0.1.0.dist-info/licenses/LICENSE,sha256=1rFsV0HhxaZBP55JM8Cu2w0Bw-uxTFtyTja_DE94oEM,1048
46
- parallel_web-0.1.0.dist-info/RECORD,,
43
+ parallel_web-0.1.1.dist-info/METADATA,sha256=CRO5bKVB_Dwpg5CGZRy_taAh6sUvRKJBrX81SJB2mmo,17504
44
+ parallel_web-0.1.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
45
+ parallel_web-0.1.1.dist-info/licenses/LICENSE,sha256=1rFsV0HhxaZBP55JM8Cu2w0Bw-uxTFtyTja_DE94oEM,1048
46
+ parallel_web-0.1.1.dist-info/RECORD,,