Skip to content

Commit

Permalink
Add posibilty of custom dagster op name
Browse files Browse the repository at this point in the history
Added the posibility of a custom dagster op name. If not set, it will default to the command generated name
  • Loading branch information
ReneTC authored Oct 11, 2023
1 parent 282e0ee commit 225b5dc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dagster_meltano/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@lru_cache
def meltano_command_op(
command: str,
dagster_name: Optional[str] = None,
dagster_name: str,
) -> OpDefinition:
"""
Run `meltano <command>` using a Dagster op.
Expand All @@ -34,13 +34,11 @@ def meltano_command_op(
Args:
command (str): The Meltano command to run.
dagster_name (Optional[str], optional): The Dagster name to use for the op.
Defaults to None.
dagster_name (str): The Dagster name to use for the op.
Returns:
OpDefinition: The Dagster op definition.
"""
dagster_name = dagster_name or generate_dagster_name(command)
ins = {
"after": In(Nothing),
"env": In(
Expand Down Expand Up @@ -101,14 +99,23 @@ def dagster_op(
@lru_cache
def meltano_run_op(
command: str,
dagster_name: Optional[str] = None,

) -> OpDefinition:
"""
Run `meltano run <command>` using a Dagster op.
This factory is cached to make sure the same commands can be reused in the
same repository.
Args:
command (str): The Meltano command to run.
dagster_name (Optional[str], optional): The Dagster name to use for the op.
Defaults to None.
"""
dagster_name = generate_dagster_name(command)
# if not set, generate a dagster_name from the command
dagster_name = dagster_name or generate_dagster_name(command)

return meltano_command_op(
command=f"run {command} --force", dagster_name=dagster_name
)
Expand Down

0 comments on commit 225b5dc

Please sign in to comment.