Hi, i am in my very first steps with dagster and d...
# dagster-plus
t
Hi, i am in my very first steps with dagster and dagster-cloud. I am still trying to just get something simple to run on snowflake. Right now i am trying this snippet https://docs.dagster.io/_apidocs/libraries/dagster-snowflake#resource. The deployment to dagster-cloud works but since there is not asset in the definition the assets are emtpy. The job doesn't show up. Is it possible to run something in dagster-cloud without an asset? Just ops?
d
Hi Tobias, it's possible run code in Dagster with just jobs, yes - assets are optional. Is it possible to share your code? You may need to add a Definitions object: https://docs.dagster.io/concepts/code-locations#defining-code-locations - and you'll need to make sure that it's loaded when your file is imported. If you can share your code we can help make sure that it's getting loaded correctly
e
@Tobias Otte, you cannot run ops independently. You need to put ops inside a job or use an asset to be able to run (materialize) it.
d
ah right - good catch Ryan . You do need at least one job, Dagster doesn't let ops live in isolation in the same way as assets
thankewe 1
t
Hi Daniel and Ryan, thank you for your help. I used this example snipped, just with the right snowflake environemnt Data. There is a job my_snowflake_job() defined, but it doesn't show up in dagster-cloud ui. So i am unable to execute.
Copy code
from dagster import job, op
from dagster_snowflake import snowflake_resource

@op(required_resource_keys={'snowflake'})
def get_one(context):
    context.resources.snowflake.execute_query('SELECT 1')

@job(resource_defs={'snowflake': snowflake_resource})
def my_snowflake_job():
    get_one()

my_snowflake_job.execute_in_process(
    run_config={
        'resources': {
            'snowflake': {
                'config': {
                    'account': {'env': 'SNOWFLAKE_ACCOUNT'},
                    'user': {'env': 'SNOWFLAKE_USER'},
                    'password': {'env': 'SNOWFLAKE_PASSWORD'},
                    'database': {'env': 'SNOWFLAKE_DATABASE'},
                    'schema': {'env': 'SNOWFLAKE_SCHEMA'},
                    'warehouse': {'env': 'SNOWFLAKE_WAREHOUSE'},
                }
            }
        }
    }
)
e
Just making sure I'm getting it right: you want to see your
my_snowflake_job
in dagit (the dagster user interface)
t
Yaeah thats right. I thought it might appear in the Overview - Jobs tab. I am competely new to dagster so that might be a wrong expetation?
e
Because in the code snippet that you have provided, you're actually just saying in your python code to run that particular job. For you to be able to view it in the UI, you need to put the job inside a
Definitions
object as what daniel has said. You can think of it like registering your job
Copy code
from dagster import job, op, graph, Definitions
from dagster_snowflake import snowflake_resource

@op(required_resource_keys={'snowflake'})
def get_one(context):
    context.resources.snowflake.execute_query('SELECT 1')

@graph
def my_snowflake_graph():
    get_one()

resource_defs={
        'snowflake': snowflake_resource.configured({
                'account': {'env': 'SNOWFLAKE_ACCOUNT'},
                'user': {'env': 'SNOWFLAKE_USER'},
                'password': {'env': 'SNOWFLAKE_PASSWORD'},
                'database': {'env': 'SNOWFLAKE_DATABASE'},
                'schema': {'env': 'SNOWFLAKE_SCHEMA'},
                'warehouse': {'env': 'SNOWFLAKE_WAREHOUSE'},
        })
}

defs = Definitions(jobs=[my_snowflake_graph.to_job(name="my_snowflake_job", resource_defs=resource_defs)])
d
The other thing is that you'll need to make sure that that Definitions object is actually loaded when your Python module is loaded - so if you're specifying a Python module, you'll either need to include that Definitions object within the
___init___.py
of that package, or import it from within the init.py file. If you use one of our example projects it should create a structure that works for loading definitions: https://docs.dagster.io/getting-started/create-new-project
e
My example should be working now 🙂. It should show your job in your dagit UI. Good luck! I gotta work now
t
Thank you, it seems like my main problem was having Definitions inside the assets instead of inity.py