Skip to content

Commit 3a37591

Browse files
tadasbartadasbarejakevc
authored
fix: batch job ID and label prior to submission (#59)
This PR addresses the issues with job names submitted to Google Batch that are too long or have incorrect characters. Closes #57 and #55. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced job name processing now automatically sanitizes names, ensuring they comply with external naming restrictions for a smoother experience. - **Chores** - Updated the automated testing workflow to replace legacy cloud authentication with streamlined MinIO setup. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Tadas Bareikis <[email protected]> Co-authored-by: Jake VanCampen <[email protected]>
1 parent 5e75c43 commit 3a37591

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

.github/workflows/ci_mocked_api.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@ jobs:
8383
- name: 'Use gcloud CLI'
8484
run: 'gcloud info'
8585

86-
# - id: 'auth'
87-
# uses: 'google-github-actions/auth@v1'
88-
# with:
89-
# credentials_json: '${{ secrets.GCP_SA_KEY }}'
90-
91-
# - name: 'Set up GCloud SDK'
92-
# uses: 'google-github-actions/setup-gcloud@v1'
86+
- name: Setup minio
87+
uses: comfuture/minio-action@v1
88+
with:
89+
access_key: minio
90+
secret_key: minio123
91+
port: 9000
9392

9493
- name: Run pytest
9594
run: |

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ version = "0.5.0"
44
description = ""
55
authors = [
66
"Vanessa Sochat <[email protected]>",
7-
"Johannes Koester <[email protected]>"
7+
"Johannes Koester <[email protected]>",
8+
"Tadas Bareikis <[email protected]>"
89
]
910
readme = "README.md"
1011
license = "MIT"

snakemake_executor_plugin_googlebatch/executor.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_labels(self, job):
5656
"""
5757
Derive default labels for the job (and add custom)
5858
"""
59-
labels = {"snakemake-job": job.name}
59+
labels = {"snakemake-job": self.fix_job_name(job.name)}
6060
for contender in self.get_param(job, "labels").split(","):
6161
if not contender:
6262
continue
@@ -93,7 +93,7 @@ def generate_jobid(self, job):
9393
Generate a random jobid
9494
"""
9595
uid = str(uuid.uuid4())
96-
return job.name.replace("_", "-") + "-" + uid[0:6]
96+
return self.fix_job_name(job.name) + "-" + uid[0:6]
9797

9898
def get_container(self, job, entrypoint=None, commands=None):
9999
"""
@@ -180,6 +180,13 @@ def get_command_writer(self, job):
180180
resources=job.resources,
181181
)
182182

183+
def fix_job_name(self, name):
184+
"""
185+
Replace illegal symbols and fix the job name length to adhere to
186+
the Google Batch API job ID and label naming restrictions
187+
"""
188+
return name.replace("_", "-").replace(".", "")[:50]
189+
183190
def run_job(self, job: JobExecutorInterface):
184191
"""
185192
Run the Google Batch job.

0 commit comments

Comments
 (0)