How can I pass default values in the pipeline and ...
# dagster-feedback
q
How can I pass default values in the pipeline and not at runtime. I am using resources. I have defined resources
Copy code
resources:
  environs:
     config:
       year: 2021
How can I tell dagster that when launching from the dagit UI, if no year config us passed, use 2020. In my Python file, I have the job defined as
Copy code
@job(resource_defs={"environs": make_values_resource(year=2020)}
def pipeline_job():
   job_a(job_b)
The idea is to pass the default value in the job definition but I am getting errors. However, when I do this, I don't get any errors:
Copy code
@job(resource_defs={"environs": make_values_resource(year=int)}
def pipeline_job():
   job_a(job_b)
Any help?
p
Hi Qwame. You can usually provide a
default_value
argument when you define the resource config schema. Can you share the body of
make_values_resource
?
q
I don't have the body, that's all I got in there
Copy code
make_values_resource(year=int)
Do I have to define
make_values_resource
elsewhere other than what I have in the code?
p
make_values_resource
looks like a resource factory function that defines a resource definition using
@resource
. Usually you can provide that definition with a config schema and provide a default value there
q
Is there an example I can look at as I'm not quite understanding it here
p
Have you checked out the
Resources
section on our docs site: https://docs.dagster.io/concepts/resources
I think you’ll be interested specifically in the section called
Resource Configuration
instead of a bare type, you might want to have
year
be a https://docs.dagster.io/_apidocs/config#dagster.Field
so that you can provide a default value
q
Will that not mean I have to pass the config to an
op
instead of a
job
?
Okay so I guess what you mean is:
Copy code
make_values_resource(year=Field(int, default_value=2020, is_required=False) )
Correct?
@prha making the year a
Field
like I have in the code above solved it for me. Thanks!
🎉 1