https://dagster.io/ logo
#ask-community
Title
# ask-community
g

geoHeil

05/15/2022, 8:09 AM
How can I target a specific repository when the workspace contains all prod, staging and local resources? I.e. in particular how can I have a prod/staging/local instance of dagster which only tries to load the prod resources (and does not kick off sensors for staging and local) .
🤖 1
i.e. by default, all 3 are loaded
(and sensors with a default status of running would start working immediately)
Or would you suggest prefixing the assets with the environment? This might prevent data loss or unintended modifications. Nonetheless, some sensors would still be triggered
j

jamie

05/16/2022, 2:27 PM
Hey @geoHeil have you tried using the
attribute
keyword (link to docs)? I believe if you updated your
workspace.yaml
to
Copy code
load_from:
  - python_package: 
      package_name: hacker_news_assets
      attribute: staging
it you just load the staging repo
🎉 1
g

geoHeil

05/18/2022, 8:23 AM
Errors while loading workspace config from /Users/geoheil/development/cybersio/poc/CYBERSIO/workspace_staging.yaml. Error 1: Received unexpected config entry "attribute" at path rootload from[0]grpc_server. Expected: "{ host?: (String | { env: String }) location_name?: (String | { env: String }) port?: (Int | { env: String }) socket?: (String | { env: String }) ssl?: Bool }".
@jamie but this seems to fail for the GRPC stuff
According to the docs: Similar to when specifying code in your
workspace.yaml
, the target can be either a python file or python package, and you can use an 'attribute' flag to identify a single repository within that target. it should work though
dagster api grpc -h 0.0.0.0 -p 4000 -f /path/to/my/repository.py --attribute <<repo_name>>
works fine though. So why is
attribute
failing when trying to load it from the yaml workspace configuration file?
d

daniel

05/18/2022, 1:49 PM
@geoHeil attribute doesn't work as an argument to grpc_server for the same reason that python_file and python_package doesn't - it expects you to have separately spun up a grpc server and passed in those arguments to
dagster api grpc
The attribute flag is applied when loading the code (which happens in the grpc server), not within dagit
g

geoHeil

05/18/2022, 1:52 PM
I thought in the most naive example
dagit
internally a) reads the workspace.yaml file and b) spins up an
grpc
server (process local). So far, I do not understand why it cannot use this flag when provided in the configuration or phrased differently: why this flag only works when applied to the CLI when manually launching a grpc server.
How can I ideally switch the targeted environments (dev, staging, prod) by only swapping the workspace yaml file?
d

daniel

05/18/2022, 1:55 PM
yeah there are two cases. In one, dagit is responsible for spinning up the server as a local subprocess. In another, you're responsible for spinning up the server and dagit just connects to it. Extending the attribute flag to also work when you're providing a grpc server is a reasonable feature request - it's just different than how its currently implemented, which is as an argument to the grpc server startup command. So when dagit isn't responsible for running the grpc server startup command, there's no way currently to apply the argument.
g

geoHeil

05/18/2022, 1:59 PM
When I have the GRPC server in docker (and supply the the workspace.yaml file as an argument) it would be really nice/useful if it would directly take the attribute parameter from the configuration. Also in the naive case where it is spun up directly - this would be useful. Do you think you can make a ticket to track this? Furthermore: Given that this is currently not implemented what would you suggest to switch the repository (wich each points to one environment for the pipeline).
d

daniel

05/18/2022, 2:00 PM
I'm not totally following what you mean by "Also in the naive case where it is spun up directly"
do you mean when specifying 'python_package' in the workspace.yaml? Attribute does work in that case, that's the example that jamie posted earlier
g

geoHeil

05/18/2022, 2:01 PM
In one, dagit is responsible for spinning up the server as a local subprocess
d

daniel

05/18/2022, 2:01 PM
Yeah, attribute works there
g

geoHeil

05/18/2022, 2:08 PM
Understood. With this I can find a solution wich should be working well enough for me now.
(i.e. no additional feature required) though it would have been more straightforward for me otherwise.
d

daniel

05/18/2022, 2:09 PM
What I would love to have long-term is the ability to have a workspace.yaml that tells dagster to spin up the gRPC servers in docker containers for you instead of subprocesses, so that you don't have to choose between the naive way and the grpc_server way
that's kind of how dagster cloud works - you can e.g. specify an image in the workspace.yaml equivalent and the agent will spin it up in a container for you
then you could specify attribute there and you'd get the best of both worlds
g

geoHeil

05/18/2022, 2:10 PM
indeed - this sounds nice.