Skip to content

Commit

Permalink
chore: bump-pydantic to 2.3.0 (#375)
Browse files Browse the repository at this point in the history
Signed-off-by: ThibaultFy <[email protected]>
  • Loading branch information
ThibaultFy authored Sep 8, 2023
1 parent 83128c7 commit 08c99ad
Show file tree
Hide file tree
Showing 14 changed files with 259 additions and 240 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Update to pydantic 2.3.0 ([#375](https://github.com/Substra/substra/pull/375))

## [0.47.0](https://github.com/Substra/substra/releases/tag/0.47.0) - 2023-09-07

### Added
Expand All @@ -16,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- warning and help message when logging in with username/password rather than token ([#378](https://github.com/Substra/substra/pull/378))
- new `Client.logout` function, mirroring `Client.login` ([#381](https://github.com/Substra/substra/pull/381))
- `Client` can now be used within a context manager ([#381](https://github.com/Substra/substra/pull/381))

```python
with Client(
client_name="org-1",
Expand Down
6 changes: 3 additions & 3 deletions bin/generate_sdk_schemas_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@


def _get_field_description(fields):
desc = [f"{field.name}: {field._type_display()}" for _, field in fields.items()]
desc = [f"{name}: {field.annotation}" for name, field in fields.items()]
return desc


Expand Down Expand Up @@ -76,7 +76,7 @@ def _create_anchor(schema):
# Write the docstring
fh.write(f"{inspect.getdoc(asset)}\n")
# List the fields and their types
description = _get_field_description(asset.__fields__)
description = _get_field_description(asset.model_fields)
fh.write("```text\n")
fh.write("- " + "\n- ".join(description))
fh.write("\n```")
Expand All @@ -89,7 +89,7 @@ def write_help(path, models: bool):


if __name__ == "__main__":
expected_pydantic_version = "1.9.0"
expected_pydantic_version = "2.3.0"
if pydantic.VERSION != expected_pydantic_version:
warnings.warn(
f"The documentation should be generated with the version {expected_pydantic_version} of pydantic or \
Expand Down
2 changes: 1 addition & 1 deletion references/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ to pandas dataframe. You can wait for compute task to finish by setting
**Examples:**
```python
perf = client.get_performances(cp_key)
df = pd.DataFrame(perf.dict())
df = pd.DataFrame(perf.model_dump())
print(df)
```
## get_task
Expand Down
174 changes: 87 additions & 87 deletions references/sdk_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,142 +18,142 @@
## DataSample
Data sample
```text
- key: str
- owner: str
- data_manager_keys: Optional[List[str]]
- path: Optional[DirectoryPath]
- creation_date: datetime
- key: <class 'str'>
- owner: <class 'str'>
- data_manager_keys: typing.Optional[typing.List[str]]
- path: typing.Optional[typing.Annotated[pathlib.Path, PathType(path_type='dir')]]
- creation_date: <class 'datetime.datetime'>
```

## Dataset
Dataset asset
```text
- key: str
- name: str
- owner: str
- permissions: Permissions
- type: str
- data_sample_keys: List[str]
- opener: _File
- description: _File
- metadata: Mapping[str, str]
- creation_date: datetime
- logs_permission: Permission
- key: <class 'str'>
- name: <class 'str'>
- owner: <class 'str'>
- permissions: <class 'substra.sdk.models.Permissions'>
- type: <class 'str'>
- data_sample_keys: typing.List[str]
- opener: <class 'substra.sdk.models._File'>
- description: <class 'substra.sdk.models._File'>
- metadata: typing.Dict[str, str]
- creation_date: <class 'datetime.datetime'>
- logs_permission: <class 'substra.sdk.models.Permission'>
```

## Task
Asset creation specification base class.
```text
- key: str
- function: Function
- owner: str
- compute_plan_key: str
- metadata: Mapping[str, str]
- status: Status
- worker: str
- rank: Optional[int]
- tag: str
- creation_date: datetime
- start_date: Optional[datetime]
- end_date: Optional[datetime]
- error_type: Optional[TaskErrorType]
- inputs: List[InputRef]
- outputs: Mapping[str, ComputeTaskOutput]
- key: <class 'str'>
- function: <class 'substra.sdk.models.Function'>
- owner: <class 'str'>
- compute_plan_key: <class 'str'>
- metadata: typing.Union[typing.Dict[str, str], typing.Dict[str, int]]
- status: <enum 'Status'>
- worker: <class 'str'>
- rank: typing.Optional[int]
- tag: <class 'str'>
- creation_date: <class 'datetime.datetime'>
- start_date: typing.Optional[datetime.datetime]
- end_date: typing.Optional[datetime.datetime]
- error_type: typing.Optional[substra.sdk.models.TaskErrorType]
- inputs: typing.List[substra.sdk.models.InputRef]
- outputs: typing.Dict[str, substra.sdk.models.ComputeTaskOutput]
```

## Function
Asset creation specification base class.
```text
- key: str
- name: str
- owner: str
- permissions: Permissions
- metadata: Mapping[str, str]
- creation_date: datetime
- inputs: List[FunctionInput]
- outputs: List[FunctionOutput]
- description: _File
- function: _File
- key: <class 'str'>
- name: <class 'str'>
- owner: <class 'str'>
- permissions: <class 'substra.sdk.models.Permissions'>
- metadata: typing.Dict[str, str]
- creation_date: <class 'datetime.datetime'>
- inputs: typing.List[substra.sdk.models.FunctionInput]
- outputs: typing.List[substra.sdk.models.FunctionOutput]
- description: <class 'substra.sdk.models._File'>
- function: <class 'substra.sdk.models._File'>
```

## ComputePlan
ComputePlan
```text
- key: str
- tag: str
- name: str
- owner: str
- metadata: Mapping[str, str]
- task_count: int
- waiting_count: int
- todo_count: int
- doing_count: int
- canceled_count: int
- failed_count: int
- done_count: int
- failed_task_key: Optional[str]
- status: ComputePlanStatus
- creation_date: datetime
- start_date: Optional[datetime]
- end_date: Optional[datetime]
- estimated_end_date: Optional[datetime]
- duration: Optional[int]
- creator: Optional[str]
- key: <class 'str'>
- tag: <class 'str'>
- name: <class 'str'>
- owner: <class 'str'>
- metadata: typing.Dict[str, str]
- task_count: <class 'int'>
- waiting_count: <class 'int'>
- todo_count: <class 'int'>
- doing_count: <class 'int'>
- canceled_count: <class 'int'>
- failed_count: <class 'int'>
- done_count: <class 'int'>
- failed_task_key: typing.Optional[str]
- status: <enum 'ComputePlanStatus'>
- creation_date: <class 'datetime.datetime'>
- start_date: typing.Optional[datetime.datetime]
- end_date: typing.Optional[datetime.datetime]
- estimated_end_date: typing.Optional[datetime.datetime]
- duration: typing.Optional[int]
- creator: typing.Optional[str]
```

## Performances
Performances of the different compute tasks of a compute plan
```text
- compute_plan_key: List[str]
- compute_plan_tag: List[str]
- compute_plan_status: List[str]
- compute_plan_start_date: List[datetime]
- compute_plan_end_date: List[datetime]
- compute_plan_metadata: List[dict]
- worker: List[str]
- task_key: List[str]
- task_rank: List[int]
- round_idx: List[int]
- identifier: List[str]
- performance: List[float]
- compute_plan_key: typing.List[str]
- compute_plan_tag: typing.List[str]
- compute_plan_status: typing.List[str]
- compute_plan_start_date: typing.List[datetime.datetime]
- compute_plan_end_date: typing.List[datetime.datetime]
- compute_plan_metadata: typing.List[dict]
- worker: typing.List[str]
- task_key: typing.List[str]
- task_rank: typing.List[int]
- round_idx: typing.List[int]
- identifier: typing.List[str]
- performance: typing.List[float]
```

## Organization
Organization
```text
- id: str
- is_current: bool
- creation_date: datetime
- id: <class 'str'>
- is_current: <class 'bool'>
- creation_date: <class 'datetime.datetime'>
```

## Permissions
Permissions structure stored in various asset types.
```text
- process: Permission
- process: <class 'substra.sdk.models.Permission'>
```

## InModel
In model of a task
```text
- checksum: str
- storage_address: Union[FilePath, AnyUrl, str]
- checksum: <class 'str'>
- storage_address: typing.Union[typing.Annotated[pathlib.Path, PathType(path_type='file')], pydantic_core._pydantic_core.Url, str]
```

## OutModel
Out model of a task
```text
- key: str
- compute_task_key: str
- address: Optional[InModel]
- permissions: Permissions
- owner: str
- creation_date: datetime
- key: <class 'str'>
- compute_task_key: <class 'str'>
- address: typing.Optional[substra.sdk.models.InModel]
- permissions: <class 'substra.sdk.models.Permissions'>
- owner: <class 'str'>
- creation_date: <class 'datetime.datetime'>
```

## _File
File as stored in the models
```text
- checksum: str
- storage_address: Union[FilePath, AnyUrl, str]
- checksum: <class 'str'>
- storage_address: typing.Union[typing.Annotated[pathlib.Path, PathType(path_type='file')], pydantic_core._pydantic_core.Url, str]
```

Loading

0 comments on commit 08c99ad

Please sign in to comment.