Commit 0c848b5
Upgrade pydantic version (#179)
* Migrate to Pydantic v2, update model validation and fix async issues
- Migrated to Pydantic v2:
- Replaced deprecated `parse_obj()` and `parse_raw()` with
`model_validate()` and `model_validate_json()`.
- Replaced `.dict()` with `.model_dump()` for serializing models to dictionaries.
- Updated `validator` to `field_validator` and `root_validator` to
`model_validator` to comply with Pydantic v2 syntax changes.
- Fixed asyncio issues:
- Added `await` for asynchronous methods like `raise_for_status()`
in `RemoteAccount` and other HTTP operations to avoid `RuntimeWarning`.
- Updated config handling:
- Used `ClassVar` for constants in `Settings` and other configuration classes.
- Replaced `Config` with `ConfigDict` in Pydantic models
to follow v2 conventions.
- Added default values for missing fields in chain configurations
(`CHAINS_SEPOLIA_ACTIVE`, etc.).
- Adjusted signature handling:
- Updated the signing logic to prepend `0x` in the `BaseAccount` signature
generation to ensure correct Ethereum address formatting.
- Minor fixes:
- Resolved issue with extra fields not being allowed by default
by specifying `extra="allow"` or `extra="forbid"` where necessary.
- Fixed tests to account for changes in model validation and
serialization behavior.
- Added `pydantic-settings` as a new dependency for configuration management.
* fix: lint tests were failing
- Updated all instances of **extra_fields to ensure proper handling of
Optional dictionaries using `(extra_fields or {})` pattern.
- Added proper return statements in `AlephHttpClient.get_message_status`
to return parsed JSON data as a `MessageStatus` object.
- Updated `Settings` class in `conf.py` to correct DNS resolvers type
and simplify the `model_config` definition.
- Refactored `parse_volume` to ensure correct handling of Mapping types
and MachineVolume types, avoiding TypeErrors.
- Improved field validation and model validation in `SignedPubKeyHeader` by
using correct Pydantic v2 validation decorators and ensuring compatibility with the new model behavior.
- Applied formatting and consistency fixes for `model_dump` usage and indentation improvements in test files.
* feat: add pyproject-fmt
* fix: run pyproject-fmt
* Post-SOL fixes (#178)
* Missing chain field on auth
* Fix Signature of Solana operation for CRN
* Add export_private_key func for accounts
* Improve _load_account
* Add chain arg to _load_account
* Increase default HTTP_REQUEST_TIMEOUT
* Typing
---------
Co-authored-by: Olivier Le Thanh Duong <olivier@lethanh.be>
* Migrate to Pydantic v2, update model validation and fix async issues
- Migrated to Pydantic v2:
- Replaced deprecated `parse_obj()` and `parse_raw()` with
`model_validate()` and `model_validate_json()`.
- Replaced `.dict()` with `.model_dump()` for serializing models to dictionaries.
- Updated `validator` to `field_validator` and `root_validator` to
`model_validator` to comply with Pydantic v2 syntax changes.
- Fixed asyncio issues:
- Added `await` for asynchronous methods like `raise_for_status()`
in `RemoteAccount` and other HTTP operations to avoid `RuntimeWarning`.
- Updated config handling:
- Used `ClassVar` for constants in `Settings` and other configuration classes.
- Replaced `Config` with `ConfigDict` in Pydantic models
to follow v2 conventions.
- Added default values for missing fields in chain configurations
(`CHAINS_SEPOLIA_ACTIVE`, etc.).
- Adjusted signature handling:
- Updated the signing logic to prepend `0x` in the `BaseAccount` signature
generation to ensure correct Ethereum address formatting.
- Minor fixes:
- Resolved issue with extra fields not being allowed by default
by specifying `extra="allow"` or `extra="forbid"` where necessary.
- Fixed tests to account for changes in model validation and
serialization behavior.
- Added `pydantic-settings` as a new dependency for configuration management.
* fix: add explicit float type for HTTP_REQUEST_TIMEOUT to comply with Pydantic v2 requirements
Pydantic v2 requires explicit type annotations for fields, so added `float`
to ensure proper validation of HTTP_REQUEST_TIMEOUT.
* Fix: Linting tests did not pass:
* Fix: Project don't use the good version of aleph-message
There were changes made on aleph-message on the main branch about
pydantic version. Using the version by the url and then change it
later after the release.
* fix: Wrong aleph-message version
* Fix: list[str] rise an error in ubuntu 20.04
Using List from typing instead to assure the compatibility between python3.8 and above
* style: isort
* fix: Hugo comments
* Add pydantic for better mypy tests + Fixes
* fix: Changing version of aleph-message
* style: Missing type for URL
* style: Missing type for URL
* fix: Changing version of aleph-message and fix mypy
Changing the version from the branch to the main of aleph-message
mypy rose some errors about missing name argument, so setting the as None because
they are optional
* fix: Changing version of aleph-message
* fix: Changing version of pytezos
* Changes for new pricing system (#199)
- Move/improve flow code parts from CLI to SDK
- Add utils functions
- Add `make_instance_content` and `make_program_content`
- Refactor `create_instance` and `create_program`
- Add `get_estimated_price`
- Fixes for mypy/ruff/pytest
- Minor improvements
- Remove firecracker rootfs hashes for instances
* Migrate to Pydantic v2, update model validation and fix async issues
- Migrated to Pydantic v2:
- Replaced deprecated `parse_obj()` and `parse_raw()` with
`model_validate()` and `model_validate_json()`.
- Replaced `.dict()` with `.model_dump()` for serializing models to dictionaries.
- Updated `validator` to `field_validator` and `root_validator` to
`model_validator` to comply with Pydantic v2 syntax changes.
- Fixed asyncio issues:
- Added `await` for asynchronous methods like `raise_for_status()`
in `RemoteAccount` and other HTTP operations to avoid `RuntimeWarning`.
- Updated config handling:
- Used `ClassVar` for constants in `Settings` and other configuration classes.
- Replaced `Config` with `ConfigDict` in Pydantic models
to follow v2 conventions.
- Added default values for missing fields in chain configurations
(`CHAINS_SEPOLIA_ACTIVE`, etc.).
- Adjusted signature handling:
- Updated the signing logic to prepend `0x` in the `BaseAccount` signature
generation to ensure correct Ethereum address formatting.
- Minor fixes:
- Resolved issue with extra fields not being allowed by default
by specifying `extra="allow"` or `extra="forbid"` where necessary.
- Fixed tests to account for changes in model validation and
serialization behavior.
- Added `pydantic-settings` as a new dependency for configuration management.
* fix: lint tests were failing
- Updated all instances of **extra_fields to ensure proper handling of
Optional dictionaries using `(extra_fields or {})` pattern.
- Added proper return statements in `AlephHttpClient.get_message_status`
to return parsed JSON data as a `MessageStatus` object.
- Updated `Settings` class in `conf.py` to correct DNS resolvers type
and simplify the `model_config` definition.
- Refactored `parse_volume` to ensure correct handling of Mapping types
and MachineVolume types, avoiding TypeErrors.
- Improved field validation and model validation in `SignedPubKeyHeader` by
using correct Pydantic v2 validation decorators and ensuring compatibility with the new model behavior.
- Applied formatting and consistency fixes for `model_dump` usage and indentation improvements in test files.
* Migrate to Pydantic v2, update model validation and fix async issues
- Migrated to Pydantic v2:
- Replaced deprecated `parse_obj()` and `parse_raw()` with
`model_validate()` and `model_validate_json()`.
- Replaced `.dict()` with `.model_dump()` for serializing models to dictionaries.
- Updated `validator` to `field_validator` and `root_validator` to
`model_validator` to comply with Pydantic v2 syntax changes.
- Fixed asyncio issues:
- Added `await` for asynchronous methods like `raise_for_status()`
in `RemoteAccount` and other HTTP operations to avoid `RuntimeWarning`.
- Updated config handling:
- Used `ClassVar` for constants in `Settings` and other configuration classes.
- Replaced `Config` with `ConfigDict` in Pydantic models
to follow v2 conventions.
- Added default values for missing fields in chain configurations
(`CHAINS_SEPOLIA_ACTIVE`, etc.).
- Adjusted signature handling:
- Updated the signing logic to prepend `0x` in the `BaseAccount` signature
generation to ensure correct Ethereum address formatting.
- Minor fixes:
- Resolved issue with extra fields not being allowed by default
by specifying `extra="allow"` or `extra="forbid"` where necessary.
- Fixed tests to account for changes in model validation and
serialization behavior.
- Added `pydantic-settings` as a new dependency for configuration management.
* Fix: Linting tests did not pass:
* fix: Wrong aleph-message version
* fix: Hugo comments
* Add pydantic for better mypy tests + Fixes
* fix: Changing version of aleph-message
* style: Missing type for URL
* fix: Changing version of aleph-message and fix mypy
Changing the version from the branch to the main of aleph-message
mypy rose some errors about missing name argument, so setting the as None because
they are optional
* fix: Changing version of aleph-message
* Fix: Missing pydantic_core and wrong version of tezos
* Fix: Access to PersistentVolumeSizeMib is incompatible after migrating to Pydantic2
Using model_validate to access it
* Fix: Wrong name given to the variable
* Style: isort
* Fix: PersistentVolumeSizeMib no longer exist
This class has been deleted from aleph_message and the size is now inside
the PersistentVolume class
* Fix: Update last `aleph-message` version and use again `PersistentVolumeSizeMib` class
* fix: invalid signature cause by `0x` + signature.hex()
* fix: add '0x' to the signature if not here (error happenings only on unit test)
* Refactor: Apply the `.hex()` quick fix on the ETHAccount class instead on the base one as other chains can be affected.
* fix: pydantic model should use `.model_dump()` instead of `dict()`
* fix: add dummy signature for unauthenticated price estimates
When estimating prices without authentication, there's no valid signature available.
This fix uses a dummy signature so that message validation passes in these cases.
---------
Co-authored-by: Laurent Peuch <cortex@worlddomination.be>
Co-authored-by: philogicae <philogicae+github@gmail.com>
Co-authored-by: Olivier Le Thanh Duong <olivier@lethanh.be>
Co-authored-by: philogicae <38438271+philogicae@users.noreply.github.com>
Co-authored-by: Andres D. Molins <amolinsdiaz@yahoo.es>
Co-authored-by: 1yam <lyam.gomes@epitech.eu>
Co-authored-by: Andres D. Molins <nesitor@gmail.com>1 parent e40033f commit 0c848b5
19 files changed
Lines changed: 134 additions & 114 deletions
File tree
- src/aleph/sdk
- chains
- client
- query
- vm
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
83 | 99 | | |
84 | 100 | | |
85 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
528 | | - | |
| 528 | + | |
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| |||
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
576 | | - | |
| 576 | + | |
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| |||
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
620 | | - | |
| 620 | + | |
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
| 624 | + | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
668 | | - | |
| 668 | + | |
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
| 465 | + | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
487 | 486 | | |
488 | 487 | | |
| 488 | + | |
| 489 | + | |
489 | 490 | | |
490 | 491 | | |
491 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
88 | | - | |
| 88 | + | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
244 | | - | |
| 243 | + | |
245 | 244 | | |
246 | 245 | | |
247 | 246 | | |
| |||
297 | 296 | | |
298 | 297 | | |
299 | 298 | | |
300 | | - | |
| 299 | + | |
301 | 300 | | |
302 | 301 | | |
303 | 302 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | | - | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
0 commit comments