Skip to content

Commit c78a12b

Browse files
tomasr8PMax5
authored andcommitted
Use raw string for a regex pattern
In recent Python versions, '\d' emits a SyntaxWarning. Use raw string to treat the backslash in '\d' as a literal backslash.
1 parent 14e19e5 commit c78a12b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

SwanSpawner/swanspawner/_gpuinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def _process_partitions(self,
336336
'''
337337
# Look for MIG partitions in the allocatable resources list
338338
for resource_name,count in node_status.allocatable.items():
339-
m = re.match('nvidia.com/mig-\d+g.(\d+)gb', resource_name) # e.g. nvidia.com/mig-1g.5gb
339+
m = re.match(r'nvidia.com/mig-\d+g.(\d+)gb', resource_name) # e.g. nvidia.com/mig-1g.5gb
340340
if m and int(count) > 0:
341341
memory = m.group(1)
342342
description = f'{gpu_model} partition ({memory} GB)'

SwanSpawner/swanspawner/swanspawner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ async def poll(self):
391391
if exit_return_code.isdigit():
392392
value_cleaned = exit_return_code
393393
else:
394-
result = re.search('ExitCode=(\d+)', exit_return_code)
394+
result = re.search(r'ExitCode=(\d+)', exit_return_code)
395395
if not result:
396396
raise Exception("unknown exit code format for this Spawner")
397397
value_cleaned = result.group(1)

0 commit comments

Comments
 (0)