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

[dagster-sigma] Detach spec loading from Sigma resource #25431

Merged
merged 5 commits into from
Oct 24, 2024

Conversation

benpankow
Copy link
Member

@benpankow benpankow commented Oct 22, 2024

Summary

As part of migrating to the APIs mocked out in https://www.notion.so/dagster/Asset-integration-customization-options-11a18b92e462807c94c2f84675021120 and https://www.notion.so/dagster/Power-BI-semantic-model-API-options-11918b92e4628006a25af3f58a6b48d9, detaches the asset spec loading process from the resource.

resource = SigmaOrganization(
    base_url=SigmaBaseUrl.AWS_US,
    client_id=EnvVar("SIGMA_CLIENT_ID"),
    client_secret=EnvVar("SIGMA_CLIENT_SECRET"),
)

sigma_specs = load_sigma_asset_specs(resource, dagster_sigma_translator=MyCoolTranslator)

How I Tested These Changes

New unit test, updated existing unit tests.

@@ -61,6 +65,9 @@ class SigmaOrganization(ConfigurableResource):
default=False,
description="Whether to warn rather than raise when lineage data cannot be fetched for an element.",
)
translator: ResourceDependency[Type[DagsterSigmaTranslator]] = Field(
Copy link
Member

Choose a reason for hiding this comment

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

hmmmm why are we making this a resource dependency? Seems like the translator should just be a vanilla object/property

Copy link
Member Author

@benpankow benpankow Oct 22, 2024

Choose a reason for hiding this comment

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

Right now all params on a resource must be either a config type or a nested resource, e.g.

E                   dagster._core.errors.DagsterInvalidPythonicConfigDefinitionError:
E                   Error defining Dagster config class <class 'dagster_sigma.resource.SigmaOrganization'> on field 'translator'.
E                   Unable to resolve config type typing.Type[dagster_sigma.translator.DagsterSigmaTranslator] to a supported Dagster config type.
E
E
E                   This config type can be a:
E                       - Python primitive type
E                           - int, float, bool, str, list
E                       - A Python Dict or List type containing other valid types
E                       - Custom data classes extending dagster.Config
E                       - A Pydantic discriminated union type (https://docs.pydantic.dev/usage/types/#discriminated-unions-aka-tagged-unions)
E
E
E                   If this config type represents a resource dependency, its annotation must either:
E                       - Extend dagster.ConfigurableResource, dagster.ConfigurableIOManager, or
E                       - Be wrapped in a ResourceDependency annotation, e.g. ResourceDependency[Type]

The actual passed translator can be a plain-old-python-object (a lowercase-r "resource", not a ConfigurableResource) - the ResourceDependency here just insists that it is not treated as config.

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

Skeptical of attaching the translator to a resource in this way as it seems confusing to me.

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

Can we just have load_sigma_asset_specs take a translator as an argument?

Comment on lines 27 to 34
resource = SigmaOrganization(
base_url=SigmaBaseUrl.AWS_US,
client_id=EnvVar("SIGMA_CLIENT_ID"),
client_secret=EnvVar("SIGMA_CLIENT_SECRET"),
translator=MyCoolTranslator,
)

sigma_specs = load_sigma_asset_specs(resource)
defs = Definitions(assets=[*sigma_specs], jobs=[define_asset_job("all_asset_job")])
Copy link
Member

Choose a reason for hiding this comment

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

Given that in all the examples that the organization is just used during the load process and not attached to the actual Definitions object I'm skeptical that it should be a resource at all. I think it adds a lot of complexity for limited benefit.

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

to your q for discussion

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

Decision:

  • Split off translator from the resource and pass it to the load function as a separate argument. The translator is only needed during the definitions load process.
  • Keep SigmaOrganization as a resource but in the examples pass it in the resources dictionary so that it is visible in the UI

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

One last thing: I think we should standardize on translate instance.

Base automatically changed from benpankow/pending-repo-load-test to master October 23, 2024 15:12
@benpankow benpankow changed the title [dagster-sigma] Detach spec loading from Sigma resource, bind translator to resource [dagster-sigma] Detach spec loading from Sigma resource Oct 23, 2024
@benpankow benpankow force-pushed the benpankow/asdf branch 2 times, most recently from aadbeb5 to 9bc6079 Compare October 24, 2024 17:52
"""Returns a list of AssetSpecs representing the Sigma content in the organization.

Args:
organization (SigmaOrganization): The Sigma organization to fetch assets from.
Copy link
Contributor

@maximearmstrong maximearmstrong Oct 24, 2024

Choose a reason for hiding this comment

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

nit: can we add the docstring for dagster_sigma_translator?

@benpankow
Copy link
Member Author

benpankow commented Oct 24, 2024

Merge activity

  • Oct 24, 1:07 PM PDT: A user started a stack merge that includes this pull request via Graphite.
  • Oct 24, 1:08 PM PDT: Graphite rebased this pull request as part of a merge.
  • Oct 24, 1:09 PM PDT: A user merged this pull request with Graphite.

@benpankow benpankow merged commit dd66c37 into master Oct 24, 2024
1 check was pending
@benpankow benpankow deleted the benpankow/asdf branch October 24, 2024 20:09
OwenKephart pushed a commit that referenced this pull request Oct 24, 2024
## Summary

As part of migrating to the APIs mocked out in https://www.notion.so/dagster/Asset-integration-customization-options-11a18b92e462807c94c2f84675021120  and https://www.notion.so/dagster/Power-BI-semantic-model-API-options-11918b92e4628006a25af3f58a6b48d9, detaches the asset spec loading process from the resource.

```python
resource = SigmaOrganization(
    base_url=SigmaBaseUrl.AWS_US,
    client_id=EnvVar("SIGMA_CLIENT_ID"),
    client_secret=EnvVar("SIGMA_CLIENT_SECRET"),
)

sigma_specs = load_sigma_asset_specs(resource, dagster_sigma_translator=MyCoolTranslator)
```

## How I Tested These Changes

New unit test, updated existing unit tests.
Grzyblon pushed a commit to Grzyblon/dagster that referenced this pull request Oct 26, 2024
…5431)

## Summary

As part of migrating to the APIs mocked out in https://www.notion.so/dagster/Asset-integration-customization-options-11a18b92e462807c94c2f84675021120  and https://www.notion.so/dagster/Power-BI-semantic-model-API-options-11918b92e4628006a25af3f58a6b48d9, detaches the asset spec loading process from the resource.

```python
resource = SigmaOrganization(
    base_url=SigmaBaseUrl.AWS_US,
    client_id=EnvVar("SIGMA_CLIENT_ID"),
    client_secret=EnvVar("SIGMA_CLIENT_SECRET"),
)

sigma_specs = load_sigma_asset_specs(resource, dagster_sigma_translator=MyCoolTranslator)
```

## How I Tested These Changes

New unit test, updated existing unit tests.
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.

3 participants