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

Cannot pass objects into their parent objects without converting to a dict #50

Open
jettdc opened this issue Oct 22, 2024 · 1 comment

Comments

@jettdc
Copy link

jettdc commented Oct 22, 2024

Currently this is invalid

created_stream = foundry_client.streams.Dataset.create(
    ...
    schema=StreamSchema(fields=[
        Field(name="value", schema=FieldSchema(nullable=False, dataType=StringType(type="string")))
    ])
)

you need to do

created_stream = foundry_client.streams.Dataset.create(
    ...
    schema=StreamSchema(fields=[
        Field(name="value", schema=FieldSchema(nullable=False, dataType=StringType(type="string")))
    ]).to_dict()
)

we should allow passing these types into functions that accept them, without converting to a dict

@jsmith
Copy link
Contributor

jsmith commented Nov 28, 2024

Currently the idea is that you instantiate the dicts directly rather than using the classes. For example:

created_stream = foundry_client.streams.Dataset.create(
    ...
    schema={"fields": [
        {"name": "value", "schema": {"nullable": False, "dataType": {"type":  "string"}}}
    ]
)

Supporting both options could definitely be something we implement in the future. We previously experimented with this option but decided to try just using dictionaries initially.

IMO, the tricky part with supporting classes is just ensuring the type definition is correct (so that pylance/mypy work as expected) and that code assist tools don't get confused by the union.

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

No branches or pull requests

2 participants