Skip to content

Commit 736a72b

Browse files
committed
Update Pydantic to version 2
- Upgrading Pydantic from version 1 to 2. This is not backwardly compatible. - Modify all `model` definitions to comply with Pydantic updates. - Upgrading Modine and Ray. - Fix tests effected by updates. - Minor updates to documentation. - No functional or API changes.
1 parent 557df92 commit 736a72b

35 files changed

+1873
-1701
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Thumbs.db
88
# Folder config file
99
Desktop.ini
1010
.vscode/
11+
*.code-workspace
1112

1213
#############
1314
## Python
@@ -32,6 +33,7 @@ develop-eggs
3233

3334
# Installer logs
3435
pip-log.txt
36+
log.txt
3537

3638
# Unit test / coverage reports
3739
.coverage

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- 1.2.0: Upgrading Pydantic from version 1.8 to version 2.10
12
- 1.1.3: Improving exception error messages to be more helpful.
23
- 1.1.2: Fixes for `CATEGORY` parser for ambiguous term names.
34
- 1.1.1: Fixes for action parser where field names contain ambiguous characters.

docs-requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
markdown==3.5.2
2+
mkdocs==1.5.3
3+
pymdown-extensions==10.7.1
4+
paginate==0.5.6
5+
mkdocs-exclude==1.0.2
6+
mkdocstrings-python==1.8.0
7+
mkdocs-redirects==1.2.1
8+
mkdocs-material==9.5.13

docs/strategies/datasource.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ datasource.validate()
7777
source data, including a [citation](#citation). If your data are accessable via a persistent url, then distributing
7878
this file ensures that all metadata definitions associated with your source data are maintained.
7979

80-
`.validate` will repeat the derivation and test that the [checksum](#derive-a-schema-from-source-data) derived for the
80+
`.validate` will repeat the derivation and test that the [checksum](#hashing-for-data-probity) derived for the
8181
model is repeatable.
8282

8383
**whyqd** can import this file and produce schemas, crosswalks and data transformations.
@@ -91,7 +91,7 @@ model is repeatable.
9191
You can read it:
9292

9393
```python
94-
datasource.get.dict(by_alias=True, exclude_defaults=True, exclude_none=True)
94+
datasource.get.model_dump(by_alias=True, exclude_defaults=True, exclude_none=True)
9595

9696
{'uuid': UUID('827941cb-fc89-4849-beea-5779fefb9f87'),
9797
'path': DATASOURCE_PATH,
@@ -236,7 +236,7 @@ Categorical terms are not validated on assignment, so if you choose to set arbit
236236
```python
237237
name = "column_1"
238238
st.set_field_categories(name=name, terms=["fish", "frog", "fennel"])
239-
st.schema.fields.get(name=name).dict(by_alias=True, exclude_defaults=True, exclude_none=True)
239+
st.schema.fields.get(name=name).model_dump(by_alias=True, exclude_defaults=True, exclude_none=True)
240240

241241
{'uuid': UUID('a43b7a94-ca6f-438d-83b9-4c84d9d7a0b7'),
242242
'name': 'column_1',

docs/strategies/schema.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ constraints = {
374374
]
375375
}
376376
schema_destination.fields.set_constraints(name="occupation_state_reliefs", constraints=constraints)
377-
schema_destination.fields.get(name="occupation_state_reliefs").dict(by_alias=True, exclude_defaults=True, exclude_none=True)
377+
schema_destination.fields.get(name="occupation_state_reliefs").model_dump(by_alias=True, exclude_defaults=True, exclude_none=True)
378378

379379
{'uuid': UUID('cf4d066e-22a8-4b76-8956-f6120eec4c52'),
380380
'name': 'occupation_state_reliefs',
@@ -398,7 +398,7 @@ schema_destination.fields.get(name="occupation_state_reliefs").dict(by_alias=Tru
398398
{'uuid': UUID('8a3af6f4-f48c-4614-83f2-ba472b2129e9'), 'name': 'other'}]}}
399399
```
400400

401-
The term `.dict(by_alias=True, exclude_defaults=True, exclude_none=True)` is used to extract a dictionary format from
401+
The term `.model_dump(by_alias=True, exclude_defaults=True, exclude_none=True)` is used to extract a dictionary format from
402402
the underlying [Pydantic](https://pydantic-docs.helpmanual.io/) model used by `whyqd`.
403403

404404
!!! info
@@ -409,7 +409,7 @@ the underlying [Pydantic](https://pydantic-docs.helpmanual.io/) model used by `w
409409
Review your schema, then `save` and we're ready to begin schema-to-schema conversion:
410410

411411
```python
412-
schema_destination.get.dict(by_alias=True, exclude_defaults=True, exclude_none=True)
412+
schema_destination.get.model_dump(by_alias=True, exclude_defaults=True, exclude_none=True)
413413

414414
{'uuid': UUID('19692345-2caf-46b1-9a8f-276491520c6b'),
415415
'name': 'test_schema',

docs/tutorials/tutorial1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ constraints = {
183183
schema_destination.fields.set_constraints(name="occupation_state_reliefs", constraints=constraints)
184184
```
185185

186-
Use `.dict(by_alias=True, exclude_defaults=True, exclude_none=True)` to extract a dictionary format from the underlying
186+
Use `.model_dump(by_alias=True, exclude_defaults=True, exclude_none=True)` to extract a dictionary format from the underlying
187187
[Pydantic](https://pydantic-docs.helpmanual.io/) model.
188188

189189
```python
190190
schema_destination.fields.get(name="occupation_state_reliefs"
191-
).dict(
191+
).model_dump(
192192
by_alias=True,
193193
exclude_defaults=True,
194194
exclude_none=True)
@@ -315,7 +315,7 @@ for ds in datasource.get:
315315
Leaving us with a list of source schema, along with their appropriate categories:
316316

317317
```python
318-
SCHEMA_SOURCE["Report1"].get.dict(by_alias=True, exclude_defaults=True, exclude_none=True)
318+
SCHEMA_SOURCE["Report1"].get.model_dump(by_alias=True, exclude_defaults=True, exclude_none=True)
319319

320320
{'uuid': UUID('a25091ef-2bad-4207-8e04-dc50760de5f9'),
321321
'name': 'portsmouth-report1',

mkdocs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ markdown_extensions:
8181
- pymdownx.highlight
8282
- pymdownx.extra
8383
- pymdownx.emoji:
84-
emoji_index: !!python/name:materialx.emoji.twemoji
85-
emoji_generator: !!python/name:materialx.emoji.to_svg
84+
emoji_index: !!python/name:material.extensions.emoji.twemoji
85+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
8686
- pymdownx.tabbed:
8787
alternate_style: true
8888

@@ -92,6 +92,8 @@ watch:
9292
plugins:
9393
- search
9494
- mkdocstrings:
95+
default_handler: python
9596
handlers:
9697
python:
97-
path: .
98+
options:
99+
show_source: false

0 commit comments

Comments
 (0)