Skip to content

Commit ac7d1e9

Browse files
committed
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 d7a0701 commit ac7d1e9

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
@@ -242,7 +242,7 @@ def _process_partitions(self,
242242
'''
243243
# Look for MIG partitions in the allocatable resources list
244244
for resource_name,count in node_status.allocatable.items():
245-
m = re.match('nvidia.com/mig-\d+g.(\d+)gb', resource_name) # e.g. nvidia.com/mig-1g.5gb
245+
m = re.match(r'nvidia.com/mig-\d+g.(\d+)gb', resource_name) # e.g. nvidia.com/mig-1g.5gb
246246
if m and int(count) > 0:
247247
memory = m.group(1)
248248
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
@@ -284,7 +284,7 @@ async def poll(self):
284284
if exit_return_code.isdigit():
285285
value_cleaned = exit_return_code
286286
else:
287-
result = re.search('ExitCode=(\d+)', exit_return_code)
287+
result = re.search(r'ExitCode=(\d+)', exit_return_code)
288288
if not result:
289289
raise Exception("unknown exit code format for this Spawner")
290290
value_cleaned = result.group(1)

0 commit comments

Comments
 (0)