Skip to content

[ISSUE] All entity model fields are optional?Β #1057

@ddluke

Description

@ddluke

Hey πŸ‘‹

I was just trying to integrate this SDK into an existing code base and immediately dropped the idea.

Can you elaborate why (from what I've seen so far) every single field in the entity model of this SDK is Optional?

This is a nightmare to use in a typed code base. After I've started to integrate the SDK into an existing typed codebase, mypy goes completely rampage.

Very simple demo code:

from databricks.sdk import WorkspaceClient
client = WorkspaceClient()

response = client.experiments.get_run(run_id="<run-id>")

# okay
print(response)
# okay
print(response.run)
# but it could be None so this fails
# error: Item "Run" of "Run | None" has no attribute "lower"  [union-attr]
print(response.run.lower())
# error: Item "None" of "Run | None" has no attribute "data"  [union-attr]
print(response.run.data)
# error: Item "None" of "Run | None" has no attribute "data"  [union-attr]
# error: Item "None" of "RunData | Any | None" has no attribute "tags"  [union-attr]
print(response.run.data.tags)

Using the dataclasses in it's current state is somewhat impossible unless I'm getting the usage of this SDK completely wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions