Skip to content
Closed
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
11 changes: 9 additions & 2 deletions snakemake_executor_plugin_googlebatch/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_labels(self, job):
"""
Derive default labels for the job (and add custom)
"""
labels = {"snakemake-job": job.name}
labels = {"snakemake-job": self.fix_job_name(job.name)}
for contender in self.get_param(job, "labels").split(","):
if not contender:
continue
Expand Down Expand Up @@ -93,7 +93,7 @@ def generate_jobid(self, job):
Generate a random jobid
"""
uid = str(uuid.uuid4())
return job.name.replace("_", "-") + "-" + uid[0:6]
return self.fix_job_name(job.name) + "-" + uid[0:6]

def get_container(self, job, entrypoint=None, commands=None):
"""
Expand Down Expand Up @@ -180,6 +180,13 @@ def get_command_writer(self, job):
resources=job.resources,
)

def fix_job_name(self, name):
"""
Replace illegal symbols and fix the job name length to adhere to
the Google Batch API job ID and label naming restrictions
"""
return name.replace("_", "-").replace(".", "")[:50]

def run_job(self, job: JobExecutorInterface):
"""
Run the Google Batch job.
Expand Down
Loading