We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from asyncio import run from prefect.blocks.core import Block from prefect.utilities.asyncutils import sync_compatible from pydantic import MongoDsn, SecretStr class ConfMongoTest(Block): uri:MongoDsn username:str|None=None password:SecretStr|None=None db:str @sync_compatible async def save_auth(): conf = ConfMongoTest(uri='mongodb://localhost:27017', db='test') await conf.save('rem-gr-auth-aquapolis', overwrite=True) async def amain(): await save_auth() if __name__ == '__main__': run(amain())
Version: 3.1.4 API version: 0.8.4 Python version: 3.12.7 Git commit: 78ee41cb Built: Wed, Nov 20, 2024 7:37 PM OS/Arch: linux/x86_64 Profile: ephemeral Server type: ephemeral Pydantic version: 2.10.1 Server: Database: sqlite SQLite version: 3.45.1 Integrations: prefect-ray: 0.4.3 prefect-dask: 0.3.2 prefect-docker: 0.6.2 prefect-aws: 0.5.2
Downgrading the pedantic version to <2.10 solves the problem
The text was updated successfully, but these errors were encountered:
hi @tonal - I'm not sure this is related to prefect, moreso pydantic (see pydantic/pydantic#10946)
in the meantime you can add a field serializer to tell pydantic how to serialize your uri
from asyncio import run from pydantic import MongoDsn, SecretStr, field_serializer from prefect.blocks.core import Block from prefect.utilities.asyncutils import sync_compatible class ConfMongoTest(Block): uri: MongoDsn username: str | None = None password: SecretStr | None = None db: str @field_serializer("uri") def serialize_uri(self, uri: MongoDsn) -> str: return str(uri) @sync_compatible async def save_auth(): conf = ConfMongoTest(uri="mongodb://localhost:27017", db="test") await conf.save("rem-gr-auth-aquapolis", overwrite=True) async def amain(): await save_auth() if __name__ == "__main__": run(amain())
Sorry, something went wrong.
No branches or pull requests
Bug summary
Version info
Additional context
Downgrading the pedantic version to <2.10 solves the problem
The text was updated successfully, but these errors were encountered: