Skip to content

Commit ddbf2bd

Browse files
authored
fix(events): correct generated models with const types (#147)
that is, values that are Literals and Enums with a single item
1 parent 0465411 commit ddbf2bd

File tree

8 files changed

+35
-26
lines changed

8 files changed

+35
-26
lines changed

cryosparc/api.pyi

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ class InstanceAPI(APINamespace):
299299
300300
"""
301301
...
302-
def audit_dump(self, *, timestamp: Union[float, str, None] = None) -> Optional[str]:
302+
def audit_dump(self, *, timestamp: Union[float, Literal["auto"], None] = None) -> Optional[str]:
303303
"""
304304
Generate an audit dump file containing all audit logs since the given timestamp.
305305
306306
Args:
307-
timestamp (float | str, optional): Leave unspecified to dump all audit logs, set to "auto" to dump new logs since the last dump, or set to a UNIX timestamp to dump every log that occurred after it.. Defaults to None
307+
timestamp (float | Literal['auto'], optional): Leave unspecified to dump all audit logs, set to "auto" to dump new logs since the last dump, or set to a UNIX timestamp to dump every log that occurred after it.. Defaults to None
308308
309309
Returns:
310310
str | None: Successful Response
@@ -1385,7 +1385,7 @@ class JobsAPI(APINamespace):
13851385
input_name: str,
13861386
/,
13871387
*,
1388-
force_join: Union[bool, str] = "auto",
1388+
force_join: Union[bool, Literal["auto"]] = "auto",
13891389
slots: Union[Literal["default", "passthrough", "all"], List[str]] = "default",
13901390
) -> Dataset:
13911391
"""
@@ -1395,7 +1395,7 @@ class JobsAPI(APINamespace):
13951395
project_uid (str): Project UID, e.g., "P3"
13961396
job_uid (str): Job UID, e.g., "J3"
13971397
input_name (str):
1398-
force_join (bool | str, optional): Defaults to 'auto'
1398+
force_join (bool | Literal['auto'], optional): Defaults to 'auto'
13991399
slots (Literal['default', 'passthrough', 'all'] | List[str], optional): Defaults to 'default'
14001400
14011401
Returns:
@@ -1410,7 +1410,7 @@ class JobsAPI(APINamespace):
14101410
output_name: str,
14111411
/,
14121412
*,
1413-
version: Union[int, str] = "F",
1413+
version: Union[int, Literal["F"]] = "F",
14141414
slots: Union[Literal["default", "passthrough", "all"], List[str]] = "default",
14151415
) -> Dataset:
14161416
"""
@@ -1420,7 +1420,7 @@ class JobsAPI(APINamespace):
14201420
project_uid (str): Project UID, e.g., "P3"
14211421
job_uid (str): Job UID, e.g., "J3"
14221422
output_name (str):
1423-
version (int | str, optional): Set to F (default) to load the final version. Defaults to 'F'
1423+
version (int | Literal['F'], optional): Set to F (default) to load the final version. Defaults to 'F'
14241424
slots (Literal['default', 'passthrough', 'all'] | List[str], optional): Defaults to 'default'
14251425
14261426
Returns:
@@ -1578,7 +1578,7 @@ class JobsAPI(APINamespace):
15781578
source_job_uid: str,
15791579
source_output_name: str,
15801580
source_result_name: str,
1581-
source_result_version: Union[int, str] = "F",
1581+
source_result_version: Union[int, Literal["F"]] = "F",
15821582
) -> Job:
15831583
"""
15841584
Adds or replaces a result within an input connection with the given output result from a different job.
@@ -1592,7 +1592,7 @@ class JobsAPI(APINamespace):
15921592
source_job_uid (str):
15931593
source_output_name (str):
15941594
source_result_name (str):
1595-
source_result_version (int | str, optional): Defaults to 'F'
1595+
source_result_version (int | Literal['F'], optional): Defaults to 'F'
15961596
15971597
Returns:
15981598
Job: Successful Response
@@ -1733,7 +1733,14 @@ class JobsAPI(APINamespace):
17331733
"""
17341734
...
17351735
def get_output_result_path(
1736-
self, project_uid: str, job_uid: str, output_name: str, result_name: str, /, *, version: Union[int, str] = "F"
1736+
self,
1737+
project_uid: str,
1738+
job_uid: str,
1739+
output_name: str,
1740+
result_name: str,
1741+
/,
1742+
*,
1743+
version: Union[int, Literal["F"]] = "F",
17371744
) -> str:
17381745
"""
17391746
Get the absolute path for a job output's dataset or volume density.
@@ -1743,7 +1750,7 @@ class JobsAPI(APINamespace):
17431750
job_uid (str): Job UID, e.g., "J3"
17441751
output_name (str):
17451752
result_name (str):
1746-
version (int | str, optional): Defaults to 'F'
1753+
version (int | Literal['F'], optional): Defaults to 'F'
17471754
17481755
Returns:
17491756
str: Successful Response
@@ -1830,7 +1837,7 @@ class JobsAPI(APINamespace):
18301837
...
18311838
def get_event_logs(
18321839
self, project_uid: str, job_uid: str, /, *, checkpoint: Optional[int] = None
1833-
) -> List[Union[Event, CheckpointEvent, TextEvent, ImageEvent, InteractiveEvent]]:
1840+
) -> List[Union[TextEvent, ImageEvent, InteractiveEvent, CheckpointEvent, Event]]:
18341841
"""
18351842
Gets all event logs for a job.
18361843
@@ -1842,7 +1849,7 @@ class JobsAPI(APINamespace):
18421849
checkpoint (int, optional): Defaults to None
18431850
18441851
Returns:
1845-
List[Union[Event, CheckpointEvent, TextEvent, ImageEvent, InteractiveEvent]]: Successful Response
1852+
List[Union[TextEvent, ImageEvent, InteractiveEvent, CheckpointEvent, Event]]: Successful Response
18461853
18471854
"""
18481855
...

cryosparc/models/asset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class GridFSFile(BaseModel):
2525
contentType: Union[
2626
Literal["text/plain", "text/csv", "text/html", "application/json", "application/xml", "application/x-troff"],
2727
Literal["application/pdf", "image/gif", "image/jpeg", "image/png", "image/svg+xml"],
28-
str,
28+
Literal["application/octet-stream"],
2929
]
3030
"""
3131
Asset content type, e.g., "image/png"

cryosparc/models/auth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# THIS FILE IS AUTO-GENERATED, DO NOT EDIT DIRECTLY
22
# SEE dev/api_generate_models.py
3+
from typing import Literal
4+
35
from pydantic import BaseModel
46

57

68
class Token(BaseModel):
79
access_token: str
8-
token_type: str
10+
token_type: Literal["bearer"]

cryosparc/models/event.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CheckpointEvent(BaseModel):
2525
avail_mb: Optional[float] = None
2626
flags: List[str] = []
2727
meta: Dict[str, Any] = {}
28-
type: str
28+
type: Literal["checkpoint"]
2929

3030

3131
class Event(BaseModel):
@@ -64,7 +64,7 @@ class ImageEvent(BaseModel):
6464
avail_mb: Optional[float] = None
6565
flags: List[str] = []
6666
meta: Dict[str, Any] = {}
67-
type: str
67+
type: Literal["image"]
6868
text: str
6969
imgfiles: List[GridFSAsset] = []
7070

@@ -97,7 +97,7 @@ class InteractiveEvent(BaseModel):
9797
avail_mb: Optional[float] = None
9898
flags: List[str] = []
9999
meta: Dict[str, Any] = {}
100-
type: str
100+
type: Literal["interactive"]
101101
subtype: str = "3dscatter"
102102
text: str
103103
datafile: InteractiveGridFSAsset

cryosparc/models/job_spec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class InputResult(BaseModel):
6868
Name of output result slot in parent job, e.g., "blob". Usually the same
6969
as "name" but may differ if there are multiple outputs of the same type
7070
"""
71-
version: Union[int, str] = "F"
71+
version: Union[int, Literal["F"]] = "F"
7272
"""
7373
Version number or specifier to use. Usually "F"
7474
"""
@@ -232,7 +232,7 @@ class Input(BaseModel):
232232
"""
233233
Minimum number of connections to this input.
234234
"""
235-
count_max: Union[int, str] = "inf"
235+
count_max: Union[int, Literal["inf"]] = "inf"
236236
"""
237237
Maximum number of connections for this input.
238238
Should be any integer >= 0 or ``"inf"`` (for infinity)
@@ -293,7 +293,7 @@ class InputSpec(BaseModel):
293293
"""
294294
Minimum number of connections to this input.
295295
"""
296-
count_max: Union[int, str] = "inf"
296+
count_max: Union[int, Literal["inf"]] = "inf"
297297
"""
298298
Maximum number of connections for this input.
299299
Should be any integer >= 0 or ``"inf"`` (for infinity)

cryosparc/models/scheduler_target.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE IS AUTO-GENERATED, DO NOT EDIT DIRECTLY
22
# SEE dev/api_generate_models.py
3-
from typing import Dict, List, Optional, Union
3+
from typing import Dict, List, Literal, Optional, Union
44

55
from pydantic import BaseModel
66

@@ -13,7 +13,7 @@ class Node(BaseModel):
1313
Node-type scheduler target that may include GPUs
1414
"""
1515

16-
type: str
16+
type: Literal["node"]
1717
"""
1818
Node scheduler targets have type "node".
1919
"""
@@ -61,7 +61,7 @@ class Cluster(BaseModel):
6161
"""
6262
Template command to check cluster queue info.
6363
"""
64-
type: str
64+
type: Literal["cluster"]
6565
"""
6666
Cluster scheduler targets have type "cluster".
6767
"""

cryosparc/models/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class AthenaVolumeUploadParams(BaseModel):
16-
type: str = "refinement"
16+
type: Literal["refinement"] = "refinement"
1717
name: str
1818
path_rel: str
1919
symmetry: str = "C1"
@@ -245,7 +245,7 @@ class Session(BaseModel):
245245
"""
246246
uid: str
247247
project_uid: str
248-
workspace_type: str = "live"
248+
workspace_type: Literal["live"] = "live"
249249
created_by_user_id: Optional[str] = None
250250
title: Optional[str] = None
251251
description: Optional[str] = None

cryosparc/models/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class User(BaseModel):
9999
name: str
100100
first_name: str
101101
last_name: str
102-
status: str = "invited"
102+
status: Literal["invited"] = "invited"
103103
profile: Profile = Profile()
104104
roles: Dict[str, List[Literal["user", "admin"]]] = {}
105105
register_token: Optional[str] = None

0 commit comments

Comments
 (0)