Skip to content

Commit

Permalink
removeprefix
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 committed Oct 30, 2024
1 parent 67b9f84 commit 0c903b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions projects/fal/src/fal/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def submit(app_id: str, arguments: dict[str, Any], *, path: str = "") -> Request
app_id = _backwards_compatible_app_id(app_id)
url = _QUEUE_URL_FORMAT.format(app_id=app_id)
if path:
url += "/" + path.removeprefix("/")
_path = path[len("/") :] if path.startswith("/") else path
url += "/" + _path

creds = get_default_credentials()

Expand Down Expand Up @@ -235,7 +236,8 @@ def _connect(app_id: str, *, path: str = "/realtime") -> Iterator[_RealtimeConne
app_id = _backwards_compatible_app_id(app_id)
url = _REALTIME_URL_FORMAT.format(app_id=app_id)
if path:
url += "/" + path.removeprefix("/")
_path = path[len("/") :] if path.startswith("/") else path
url += "/" + _path

creds = get_default_credentials()

Expand Down
8 changes: 7 additions & 1 deletion projects/fal/src/fal/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ def parse_leaf(raw_leaf: str) -> Leaf:
f"Invalid leaf: {raw_leaf} (must start with a reference)"
)

leaf: Leaf = ReferenceLeaf(reference.removeprefix(VARIABLE_PREFIX))
# remove the $ prefix
_reference = (
reference[len(VARIABLE_PREFIX) :]
if reference.startswith(VARIABLE_PREFIX)
else reference
)
leaf: Leaf = ReferenceLeaf(_reference)
for raw_part in raw_parts:
if raw_part.isdigit():
leaf = IndexLeaf(leaf, int(raw_part))
Expand Down

0 comments on commit 0c903b0

Please sign in to comment.