Skip to content
New issue

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

[Test] Test Alessio's fix to schema generation #671

Closed
wants to merge 12 commits into from

Conversation

CodyCBakerPhD
Copy link
Member

No description provided.

self, file_paths: list[str | Path], verbose: bool = False
self, file_paths: list, verbose: bool = False
Copy link
Member Author

Choose a reason for hiding this comment

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

Supporting the ability for people to call from __future__ import annotations in the library is one thing; adding full support for schema inference from data interface signatures of the updated kind is another, and would in preferance be done with Pydantic

Removing for now

Comment on lines 134 to 135
if isinstance(arg, str):
arg = type(arg)
Copy link
Member Author

Choose a reason for hiding this comment

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

Well, apparently all the new types under this behavior become str and so everything gets mapped to string in the JSON type map...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not we just use https://github.com/shawwn/get-annotations for python < 3.10

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's try it!

Copy link
Member Author

Choose a reason for hiding this comment

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

Despite the input argument eval_str saying it handles exactly this case, it doesn't look like it actually does what is says anywhere, and ends up at https://github.com/shawwn/get-annotations/blob/main/get_annotations/__init__.py#L86 regardless

@@ -130,6 +131,9 @@ def get_schema_from_method_signature(method: Callable, exclude: list = None) ->
input_schema["properties"].update({param_name: dict(format="directory")})
else:
arg = param.annotation
# in case __future__.annotations is imported, the annotation is a string
if isinstance(arg, str):
arg = eval(arg)
Copy link
Member Author

Choose a reason for hiding this comment

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

Though note this could cause security risks. Should check and limit its application to the set of basic keys supported in the json mapping dictionary, if this works at all

@CodyCBakerPhD
Copy link
Member Author

Yeah IDK my efforts here can resolve the issues with common source data patterns, but the same logic is applied to conversion options and there are some cases that cause more and other issues after that

I think we might just want to fix this by offloading all the effort required to Pydantic as in re-implementing #264

@CodyCBakerPhD
Copy link
Member Author

replaced by #1016

@CodyCBakerPhD CodyCBakerPhD deleted the test_alessio_fix branch August 19, 2024 05:40
@CodyCBakerPhD CodyCBakerPhD restored the test_alessio_fix branch August 19, 2024 05:40
@CodyCBakerPhD CodyCBakerPhD deleted the test_alessio_fix branch August 19, 2024 05:40
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.

2 participants