Skip to content

Commit

Permalink
ayush fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyworkman committed Nov 12, 2023
1 parent b7fb718 commit 9923078
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 7 additions & 9 deletions latch_cli/snakemake/config/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from latch_cli.snakemake.workflow import reindent
from latch_cli.utils import identifier_from_str

from ..serialize_utils import best_effort_display_name
from .utils import JSONValue, get_preamble, parse_type, parse_value, type_repr

T = TypeVar("T")
Expand Down Expand Up @@ -82,15 +83,10 @@ def generate_metadata(
is_file = typ in {LatchFile, LatchDir}
param_typ = "SnakemakeFileParameter" if is_file else "SnakemakeParameter"

def _best_effort_display_name(param_name: str):
if param_name[0] == "_":
param_name = param_name[1:]
return " ".join(map(lambda x: x.capitalize(), param_name.split("_")))

param_str = reindent(
f"""\
{repr(identifier_from_str(k))}: {param_typ}(
display_name={repr(_best_effort_display_name(k))},
display_name={repr(best_effort_display_name(k))},
type={type_repr(typ)},
__config____default__),""",
0,
Expand Down Expand Up @@ -132,9 +128,11 @@ def _best_effort_display_name(param_name: str):
old_metadata_path.rename(metadata_path)
elif old_metadata_path.exists() and metadata_path.exists():
click.secho(
"Warning: Found both `latch_metadata.py` and"
" `latch_metadata/__init__.py` in current directory."
" `latch_metadata.py` will be ignored.",
(
"Warning: Found both `latch_metadata.py` and"
" `latch_metadata/__init__.py` in current directory."
" `latch_metadata.py` will be ignored."
),
fg="yellow",
)

Expand Down
6 changes: 6 additions & 0 deletions latch_cli/snakemake/serialize_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import Dict, Union

from flytekit import LaunchPlan
Expand Down Expand Up @@ -210,3 +211,8 @@ def get_serializable_workflow(
admin_wf = admin_workflow_models.WorkflowSpec(template=wf_t, sub_workflows=[])
cache[entity] = admin_wf
return admin_wf


def best_effort_display_name(x: str):
expr = re.compile(r"_+")
return expr.sub(" ", x).title().strip()

0 comments on commit 9923078

Please sign in to comment.