@@ -251,12 +251,9 @@ def set_gres_string(job: JobExecutorInterface) -> str:
251251 based on the resources requested in the job.
252252 """
253253 # generic resources (GRES) arguments can be of type
254- # "string:int" or "string:string:int"
255- gres_re = re .compile (r"^[a-zA-Z0-9_]+(:[a-zA-Z0-9_\.]+)?:\d+$" )
254+ # "string:int" or "string:string:int" with optional postfix 'T' or 'G' or 'M'
255+ gres_re = re .compile (r"^[a-zA-Z0-9_]+(:[a-zA-Z0-9_\.]+)?:\d+[TGM]? $" )
256256
257- # generic resources (GRES) arguments can be of type
258- # "string:int[TGM]" when a tmpspace is specified.
259- gres_tmpspace_re = re .compile (r"^tmpspace:\d+[TGM]?$" )
260257 # gpu model arguments can be of type "string"
261258 # The model string may contain a dot for variants, see
262259 # https://github.com/snakemake/snakemake-executor-plugin-slurm/issues/387
@@ -286,24 +283,21 @@ def set_gres_string(job: JobExecutorInterface) -> str:
286283 if job .resources .get ("gres" ):
287284 # Validate GRES format (e.g., "gpu:1", "gpu:tesla:2")
288285 gres = job .resources .gres
289- if not gres_re .match (gres ):
290- if not gres_tmpspace_re .match (gres ):
291- if not string_check .match (gres ):
292- raise WorkflowError (
293- "GRES format should not be a nested string (start "
294- "and end with ticks or quotation marks). "
295- "Expected format: "
296- "'<name>:<number>' or '<name>:<type>:<number>' or "
297- "'tmpspace:<number>[TGM]' "
298- "(e.g., 'gpu:1' or 'gpu:tesla:2') or tmpspace:10G "
299- )
300- else :
301- raise WorkflowError (
302- f"Invalid GRES format: { gres } . Expected format: "
303- "'<name>:<number>' or '<name>:<type>:<number>' "
304- "or 'tmpspace:<number>[TGM]' "
305- "(e.g., 'gpu:1' or 'gpu:tesla:2') or tmpspace:10G "
306- )
286+ if not gres_re .match (gres
287+ if not string_check .match (gres ):
288+ raise WorkflowError (
289+ "GRES format should not be a nested string (start "
290+ "and end with ticks or quotation marks). "
291+ "Expected format: "
292+ "'<name>:<number>' or '<name>:<type>:<number>' with an optional 'T' 'M' or 'G' postfix "
293+ "(e.g., 'gpu:1' or 'gpu:tesla:2') "
294+ )
295+ else :
296+ raise WorkflowError (
297+ f"Invalid GRES format: { gres } . Expected format: "
298+ "'<name>:<number>' or '<name>:<type>:<number>' with an optional 'T' 'M' or 'G' postfix"
299+ "(e.g., 'gpu:1' or 'gpu:tesla:2') "
300+ )
307301 return f" --gres={ job .resources .gres } "
308302
309303 if gpu_model and gpu_string :
0 commit comments