Conversation
…into 38-update-to-pydantic-v2
…scheduler to be upgraded
…38-update-to-pydantic-v2
| from asyncio import run as aiorun | ||
|
|
||
| import typer | ||
| from apscheduler.events import EVENT_JOB_ERROR, EVENT_JOB_EXECUTED |
There was a problem hiding this comment.
Had to replace rocketry with apscheduler as rocketry has a dependency on pydantic. Currently rocketry is using pydantic v1.
| funder.name = self.funding_agency_name | ||
| if self.funding_agency_url: | ||
| funder.url = self.funding_agency_url | ||
| funder.url = str(self.funding_agency_url) |
There was a problem hiding this comment.
Should the Organization.funder.url attribute be updated to an HttpUrl instead of casting to a string here?
There was a problem hiding this comment.
The funder url has been updated to type HttpUrl:
https://github.com/I-GUIDE/catalogapi/blob/38-update-to-pydantic-v2/api/adapters/hydroshare.py#L53
| if self.testing: | ||
| self.database_name = f"{self.database_name}" | ||
| self.hydroshare_meta_read_url = str(self.hydroshare_meta_read_url) | ||
| self.hydroshare_file_read_url = str(self.hydroshare_file_read_url) |
There was a problem hiding this comment.
hmm, there must be something else going on with the HttpUrl->str conversions that I'm not understanding. Why are these lines in here?
There was a problem hiding this comment.
This also was a big headche for me when doing this upgrade. See this pydantic discussion where it talks about the problem with pydantic HttpUrl type.
pydantic/pydantic#6395
|
|
||
| class Config: | ||
| env_file = ".env" | ||
| model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8") |
There was a problem hiding this comment.
Just noting that I have since learned that if we leave the env_file Config out then it just reads environment variables which eases deployments. This comment is not relevant to these changes, just making a note here.
| # two possible types - one of which is null (due to the field being optional) | ||
| json_schema = handler(core_schema) | ||
| json_schema = handler.resolve_ref_schema(json_schema) | ||
| for field in ("url", "description"): |
There was a problem hiding this comment.
These one off json schema modifiers look hairy. Any way we can consolidate these changes to the base class and make the changes for certain types of attributes?
| @model_validator(mode='after') | ||
| def url_to_string(self): | ||
| if self.url is not None: | ||
| self.url = str(self.url) |
There was a problem hiding this comment.
I'm missing something on these httpurl to str conversions. Why is this change needed?
sblack-usu
left a comment
There was a problem hiding this comment.
It mostly looks good. I just have the question around the httpurl->str conversions and also would like to revisite the json schema modifications to see if we can make the changes more general by type instead of having custom implementations in each class.
No description provided.