Hi all, I am struggling with updating my SDA code ...
# ask-community
b
Hi all, I am struggling with updating my SDA code for 0.15.0 😕 I want to do two things: 1.
load_assets_from_modules
is not working for me - I want to be able to load all the assets from a module (e.g. raw_assets) and apply the 'group_name'. I seem to be able to run this function, but how do I input it into
with_resources
? I get the error
AttributeError: 'list' object has no attribute 'with_resources'
. 2. Be able to build job from assets. I've tried using
define_asset_job
but I just can't find clear documentation on the parameters inside, and how it fits into the final repository definition. Looking at the API docs, I'm not sure how to input my multi-key assets. I'm not sure if it's me but I'm having a hard time finding enough documentation around the new functions 😕
🤖 1
g
https://github.com/geoHeil/dagster-ssh-demo/pull/1/files illustrates some of the necessary changes
🎉 1
s
Hey Barry - of
define_asset_job
with `with_resources`:
Copy code
from dagster import with_resources, define_asset_job, load_assets_from_modules, repository

assets = load_assets_from_modules(..., group_name=...)
my_asset_job = define_asset_job("my_job", selection=...)

@repository
def prod():
    assets_with_prod_resources = with_resources(assets, prod_resources)
    return [*assets_with_prod_resources, my_asset_job]
An advantage of this approach is that, if you want to use different resources on the same assets in production / staging / dev, you don't need to load your assets and define your job separately for each environment.
🎉 1
❤️ 2
Be able to build job from assets. I've tried using
define_asset_job
but I just can't find clear documentation on the parameters inside, and how it fits into the final repository definition.
It looks like we missed including
AssetSelection
in our apidocs. I'll get that fixed.
Looking at the API docs, I'm not sure how to input my multi-key assets.
Is the there a way you were doing this with the pre-0.15.0 APIs?
b
Thanks both! Super helpful 🙂 @sandy looks like I was putting my job inside `with_resources`😅 Re the multi-key assets, I was using namespaces before and just putting the assets together in a job.
s
Re the multi-key assets, I was using namespaces before and just putting the assets together in a job.
if you were doing this before:
Copy code
build_assets_job(name=..., assets=[asset1, ...])
you can do this now:
Copy code
define_asset_job(name=..., selection=AssetSelection.assets(asset1, ...))
would that work for you?
🎉 1
b
Thanks @sandy I'll give it a go 🙂