Open nrsmac opened 3 weeks ago
Hi @nrsmac - @nicklausroach and I are going to explore this, and plan to update the documentation accordingly.
The replicate
method passes the environment variables to the Sling subprocess. So one possible solution is to set the environment variables from the partition key. For example:
@sling_assets(
replication_config=config_dir / "example.yaml",
dagster_sling_translator=CustomSlingTranslatorMain(),
partitions_def=DailyPartitionsDefinition(start_date=datetime.now()),
)
def example_sling_assets(context, embedded_elt: SlingResource):
start_date = context.partition_key
os.environ['START_DATE'] = start_date
os.environ['END_DATE'] = start_date + timedelta(days=1)
yield from embedded_elt.replicate(context=context)
Will keep you posted as we update docs. Please let me know if you make any progress yourself. Thanks!
What's the issue or suggestion?
There isn't a clear documented way to use partitions in Sling. I see I can provide a
partitions_def
but how do those values pass to Sling for a backfill? https://docs.dagster.io/_apidocs/libraries/dagster-embedded-elt#sling-dagster-embedded-elt-slingMy defined asset:
In the Sling documentation, it gives an example of passing environment variables to Sling https://docs.slingdata.io/sling-cli/run/configuration/variables.
replication.yml:
Additional information
No response
Message from the maintainers
Impacted by this issue? Give it a 👍! We factor engagement into prioritization.