This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable flow run suspend/resume with Cloud Run workers via unique Job …
…names (#249) * cloud run job unique names * fix populate name test * fix v2 job name test * update test name * add tests * update changelog * slugify job name * slugify tests * correct docstring * remove changelog * make slugify public * formatting ugh
- Loading branch information
1 parent
6bc4283
commit 72bc6ea
Showing
6 changed files
with
112 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
``` | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import Optional | ||
|
||
from slugify import slugify | ||
|
||
|
||
def slugify_name(name: str, max_length: int = 30) -> Optional[str]: | ||
""" | ||
Slugify text for use as a name. | ||
Keeps only alphanumeric characters and dashes, and caps the length | ||
of the slug at 30 chars. | ||
The 30 character length allows room to add a uuid for generating a unique | ||
name for the job while keeping the total length of a name below 63 characters, | ||
which is the limit for Cloud Run job names. | ||
Args: | ||
name: The name of the job | ||
Returns: | ||
The slugified job name or None if the slugified name is empty | ||
""" | ||
slug = slugify( | ||
name, | ||
max_length=max_length, | ||
regex_pattern=r"[^a-zA-Z0-9-]+", | ||
) | ||
|
||
return slug if slug else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters