Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: Strip equal sign in generate_dagster_name() and add possibillity of custom dagster_name #45

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion dagster_meltano/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def generate_dagster_name(input_string) -> str:
"""
Generate a dagster safe name (^[A-Za-z0-9_]+$.)
"""
return input_string.replace("-", "_").replace(" ", "_").replace(":", "_")
return input_string.replace("-", "_").replace(" ", "_").replace(":", "_").replace("=", "_")


def generate_dbt_group_name(node_info: dict) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_meltano_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@job(resource_defs={"meltano": meltano_resource})
def meltano_command_job():
meltano_command_op("install extractor tap-smoke-test")()
meltano_command_op("install extractor tap-smoke-test", "custom_job_name")()


def test_meltano_command():
Expand Down