Git Product home page Git Product logo

Comments (3)

cmpadden avatar cmpadden commented on August 25, 2024 1

@temminks, Ok, I think I've found the issue with what you've shared above. Both @sling_assets and replicate() take a DagsterSlingTranslator implementation. You've only added it to the replicate call. If you change this to the following it should work as expected.

# before
@sling_assets(replication_config=replication_config)
def gfdi_to_transformator_assets(context, sling: SlingResource):
    yield from sling.replicate(
        replication_config=replication_config,
        dagster_sling_translator=DagsterSlingTranslator(target_prefix="my_prefix"),
    )
   
# after
custom_dagster_sling_translator = DagsterSlingTranslator(target_prefix="my_prefix")
@sling_assets(replication_config=replication_config, dagster_sling_translator=custom_dagster_sling_translator)
def gfdi_to_transformator_assets(context, sling: SlingResource):
    yield from sling.replicate(
        replication_config=replication_config,
        dagster_sling_translator=custom_dagster_sling_translator,
    )

I believe that we can remove the dependency to pass the translator in two locations; I will create a ticket to track such an enhancement.

from dagster.

cmpadden avatar cmpadden commented on August 25, 2024

EDIT: disregard this message, and see the comment below!


Hi @temminks - thanks again for reporting this.

If you override the class without the @dataclass decorator, then the overridden target_prefix attribute will not be set, however, the use you showed with DagsterSlingTranslator(target_prefix='custom') seems like it should work -- I will investigate further.

from dataclasses import dataclass

@dataclass
class ExampleTranslator:
    target_prefix: str = "target"


t1 = ExampleTranslator()
t1.target_prefix
# 'target'


@dataclass  # <-- with dataclass decorator
class Custom(ExampleTranslator):
    target_prefix: str = "custom"

t2 = Custom()
t2.target_prefix
# 'custom' <-- 👍 


class CustomNotDataclass(DagsterSlingTranslator):
    target_prefix: str = "custom"

t3 = CustomNotDataclass()

t3.target_prefix
# 'target' <-- 👎 

t4 = DagsterSlingTranslator(target_prefix='custom')
t4.target_prefix
# 'custom'  <-- 👍 

from dagster.

cmpadden avatar cmpadden commented on August 25, 2024

Just to follow up here, a code change was pushed that makes it so you only have to specify the translator and replication config in the asset decorator. This is to avoid the confusion of the above scenario. You can see the details here:

#20564

This change also makes it so you can use the Sling integration from an @op directly if desired.

from dagster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.