https://dagster.io/ logo
#ask-ai
Title
# ask-ai
f

Francoise Belmi

03/13/2024, 3:54 AM
@asset is not detected when inside a class
s

Scout

03/13/2024, 3:54 AM
In Dagster, assets are typically defined using the
@asset
decorator on top-level functions. The documentation does not provide an example or explicit support for defining assets within a class. If you are trying to define an asset within a class and it is not being detected, this could be because Dagster expects assets to be defined as standalone functions, not as methods within a class. To ensure that your asset is detected, you should define it as a top-level function in your module. Here is an example of how to define an asset using the
@asset
decorator:
Copy code
python from dagster import asset  @asset def my_asset():     # Your asset code here     ...
If you need to organize your assets within a class-like structure for code organization purposes, you might consider using modules or separate Python files to group related assets together, rather than using classes. If you are encountering issues with assets not being detected when defined in a certain way, please ensure that you are following the patterns shown in the documentation. If the problem persists, you may want to check for any relevant issues or discussions in the Dagster GitHub repository or consider reaching out to the community for support.
3 Views