Skip to content

Commit

Permalink
docker cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevc committed Jan 28, 2025
1 parent 504d884 commit a17d9b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions snakemake_executor_plugin_aws_batch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
__license__ = "MIT"

from dataclasses import dataclass, field
import shlex
from pprint import pformat
from typing import List, AsyncGenerator, Optional
from snakemake_executor_plugin_aws_batch.batch_client import BatchClient
Expand Down Expand Up @@ -132,8 +131,7 @@ def run_job(self, job: JobExecutorInterface):
# If required, make sure to pass the job's id to the job_info object, as keyword
# argument 'external_job_id'.

remote_command = f"/bin/bash -c {shlex.quote(self.format_job_exec(job))}"
self.logger.debug(f"Remote command: {remote_command}")
remote_command = f"/bin/bash -c {self.format_job_exec(job)}"

try:
job_definition = BatchJobBuilder(
Expand Down Expand Up @@ -212,10 +210,12 @@ def _get_job_status(self, job: SubmittedJobInfo) -> tuple[int, Optional[str]]:
exit_code = None
log_stream_name = None
job_desc = self._describer.describe(self.batch_client, job.external_jobid, 1)
self.logger.debug(f"JOB DESCRIPTION: {job_desc}")
job_status = job_desc["status"]

# set log stream name if not none
log_details = {"status": job_status, "jobId": job.external_jobid}
self.logger.debug(f"LOG DETAILS: {log_details}")

if "container" in job_desc and "logStreamName" in job_desc["container"]:
log_stream_name = job_desc["container"]["logStreamName"]
Expand Down
11 changes: 10 additions & 1 deletion snakemake_executor_plugin_aws_batch/batch_job_builder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import uuid
import shlex
from typing import List
from snakemake.exceptions import WorkflowError
from snakemake_interface_executor_plugins.jobs import (
JobExecutorInterface,
Expand Down Expand Up @@ -43,6 +45,12 @@ def __init__(
self.batch_client = batch_client
self.created_job_defs = []

def _make_container_command(remote_command: str) -> List[str]:
"""
Return docker CMD form of the command
"""
return [shlex.quote(part) for part in shlex.split(str)]

def build_job_definition(self):
job_uuid = str(uuid.uuid4())
job_name = f"snakejob-{self.job.name}-{job_uuid}"
Expand All @@ -55,7 +63,8 @@ def build_job_definition(self):

container_properties = {
"image": self.container_image,
"command": [self.job_command],
# command requires a list of strings ( docker CMD format )
"command": self._make_container_command(self.job_command),
"jobRoleArn": self.settings.job_role,
"privileged": True,
"resourceRequirements": [
Expand Down

0 comments on commit a17d9b6

Please sign in to comment.