Skip to content

Conversation

@pkdash
Copy link
Contributor

@pkdash pkdash commented Aug 14, 2023

No description provided.

@pkdash pkdash linked an issue Sep 19, 2023 that may be closed by this pull request
from asyncio import run as aiorun

import typer
from apscheduler.events import EVENT_JOB_ERROR, EVENT_JOB_EXECUTED
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to replace rocketry with apscheduler as rocketry has a dependency on pydantic. Currently rocketry is using pydantic v1.

@pkdash pkdash marked this pull request as ready for review November 1, 2023 03:24
@pkdash pkdash requested a review from sblack-usu November 1, 2023 03:25
funder.name = self.funding_agency_name
if self.funding_agency_url:
funder.url = self.funding_agency_url
funder.url = str(self.funding_agency_url)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the Organization.funder.url attribute be updated to an HttpUrl instead of casting to a string here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, there must be something else going on with the HttpUrl->str conversions that I'm not understanding. Why are these lines in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm missing something on these httpurl to str conversions. Why is this change needed?

Copy link
Collaborator

@sblack-usu sblack-usu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to pydantic v2

3 participants