Skip to content

Commit

Permalink
do not depend on encode_target_jobs_cli_args
Browse files Browse the repository at this point in the history
Signed-off-by: maximsmol <[email protected]>
  • Loading branch information
maximsmol committed Jul 22, 2023
1 parent 09d0561 commit 8be9cf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion latch_cli/docker_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def generate_dockerfile(
)
f.write("run pip uninstall --yes latch\n")
f.write(
"run echo 71 && pip install"
"run echo 72 && pip install"
" 'git+https://github.com/latchbio/latch.git@maximsmol/snakekit-1'\n"
)

Expand Down
25 changes: 18 additions & 7 deletions latch_cli/snakemake/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import textwrap
import typing
from collections.abc import Generator, Iterable
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union
Expand Down Expand Up @@ -35,8 +36,7 @@
from flytekit.models.core.types import BlobType
from flytekit.models.literals import Blob, BlobMetadata, Literal, LiteralMap, Scalar
from snakemake.dag import DAG
from snakemake.jobs import GroupJob
from snakemake.target_jobs import encode_target_jobs_cli_args
from snakemake.jobs import GroupJob, Job
from typing_extensions import TypeAlias, TypedDict

import latch.types.metadata as metadata
Expand All @@ -48,6 +48,17 @@
SnakemakeInputVal: TypeAlias = snakemake.io._IOFile


# old snakemake did not have encode_target_jobs_cli_args
def jobs_cli_args(
jobs: Iterable[Job],
) -> Generator[str, None, None]:
for x in jobs:
wildcards = ",".join(
f"{key}={value}" for key, value in x.wildcards_dict.items()
)
yield f"{x.rule.name}:{wildcards}"


T = TypeVar("T")


Expand Down Expand Up @@ -1035,13 +1046,17 @@ def get_fn_code(
1,
)

jobs = [self.job]
if isinstance(self.job, GroupJob):
jobs = self.job.jobs

snakemake_args = [
"-m",
"latch_cli.snakemake.single_task_snakemake",
"-s",
snakefile_path_in_container,
"--target-jobs",
*encode_target_jobs_cli_args(self.job.get_target_spec()),
*jobs_cli_args(jobs),
"--allowed-rules",
*self.job.rules,
"--local-groupid",
Expand All @@ -1062,10 +1077,6 @@ def get_fn_code(
for resource, value in allowed_resources:
snakemake_args.append(f"{resource}={value}")

jobs = [self.job]
if isinstance(self.job, GroupJob):
jobs = self.job.jobs

snakemake_data = {
"rules": {},
"outputs": self.job.output,
Expand Down

0 comments on commit 8be9cf6

Please sign in to comment.