fal 1.26.6__py3-none-any.whl → 1.27.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fal might be problematic. Click here for more details.
- fal/_fal_version.py +2 -2
- fal/toolkit/file/file.py +1 -1
- fal/toolkit/image/image.py +2 -2
- fal/toolkit/utils/download_utils.py +26 -2
- {fal-1.26.6.dist-info → fal-1.27.1.dist-info}/METADATA +1 -1
- {fal-1.26.6.dist-info → fal-1.27.1.dist-info}/RECORD +9 -9
- {fal-1.26.6.dist-info → fal-1.27.1.dist-info}/WHEEL +0 -0
- {fal-1.26.6.dist-info → fal-1.27.1.dist-info}/entry_points.txt +0 -0
- {fal-1.26.6.dist-info → fal-1.27.1.dist-info}/top_level.txt +0 -0
fal/_fal_version.py
CHANGED
fal/toolkit/file/file.py
CHANGED
|
@@ -61,7 +61,7 @@ def get_builtin_repository(id: RepositoryId | FileRepository) -> FileRepository:
|
|
|
61
61
|
get_builtin_repository.__module__ = "__main__"
|
|
62
62
|
|
|
63
63
|
DEFAULT_REPOSITORY: FileRepository | RepositoryId = "fal_v3"
|
|
64
|
-
FALLBACK_REPOSITORY: FileRepository | RepositoryId = "fal"
|
|
64
|
+
FALLBACK_REPOSITORY: list[FileRepository | RepositoryId] = ["cdn", "fal"]
|
|
65
65
|
OBJECT_LIFECYCLE_PREFERENCE_KEY = "x-fal-object-lifecycle-preference"
|
|
66
66
|
|
|
67
67
|
|
fal/toolkit/image/image.py
CHANGED
|
@@ -104,7 +104,7 @@ class Image(File):
|
|
|
104
104
|
file_name: str | None = None,
|
|
105
105
|
repository: FileRepository | RepositoryId = DEFAULT_REPOSITORY,
|
|
106
106
|
fallback_repository: Optional[
|
|
107
|
-
FileRepository | RepositoryId
|
|
107
|
+
FileRepository | RepositoryId | list[FileRepository | RepositoryId]
|
|
108
108
|
] = FALLBACK_REPOSITORY,
|
|
109
109
|
request: Optional[Request] = None,
|
|
110
110
|
) -> Image:
|
|
@@ -128,7 +128,7 @@ class Image(File):
|
|
|
128
128
|
file_name: str | None = None,
|
|
129
129
|
repository: FileRepository | RepositoryId = DEFAULT_REPOSITORY,
|
|
130
130
|
fallback_repository: Optional[
|
|
131
|
-
FileRepository | RepositoryId
|
|
131
|
+
FileRepository | RepositoryId | list[FileRepository | RepositoryId]
|
|
132
132
|
] = FALLBACK_REPOSITORY,
|
|
133
133
|
request: Optional[Request] = None,
|
|
134
134
|
) -> Image:
|
|
@@ -6,6 +6,7 @@ import os
|
|
|
6
6
|
import shutil
|
|
7
7
|
import subprocess
|
|
8
8
|
import sys
|
|
9
|
+
import time
|
|
9
10
|
from contextlib import suppress
|
|
10
11
|
from pathlib import Path, PurePath
|
|
11
12
|
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
|
@@ -345,6 +346,14 @@ def _stream_url_data_to_file(
|
|
|
345
346
|
raise DownloadError("Received less data than expected from the server.")
|
|
346
347
|
|
|
347
348
|
|
|
349
|
+
def _mark_used_dir(dir: Path):
|
|
350
|
+
used_file = dir / ".fal_used"
|
|
351
|
+
day_ago = time.time() - 86400
|
|
352
|
+
if not used_file.exists() or used_file.stat().st_mtime < day_ago:
|
|
353
|
+
# Touch a last-used file to indicate that the weights have been used
|
|
354
|
+
used_file.touch()
|
|
355
|
+
|
|
356
|
+
|
|
348
357
|
def download_model_weights(
|
|
349
358
|
url: str, force: bool = False, request_headers: dict[str, str] | None = None
|
|
350
359
|
) -> Path:
|
|
@@ -375,19 +384,34 @@ def download_model_weights(
|
|
|
375
384
|
|
|
376
385
|
if weights_dir.exists() and not force:
|
|
377
386
|
try:
|
|
378
|
-
|
|
387
|
+
# TODO: sometimes the directory can hold multiple files
|
|
388
|
+
# Example:
|
|
389
|
+
# .fal/model_weights/00155dc2d9579360d577d1a87d31b52c21135c14a5f44fcbab36fbb8352f3e0d # noqa: E501
|
|
390
|
+
# We need to either not allow multiple files in the directory or
|
|
391
|
+
# find the one that is the most recently used.
|
|
392
|
+
weights_path = next(
|
|
393
|
+
# Ignore .fal dotfiles since they are metadata files
|
|
394
|
+
f
|
|
395
|
+
for f in weights_dir.glob("*")
|
|
396
|
+
if not f.name.startswith(".fal")
|
|
397
|
+
)
|
|
398
|
+
_mark_used_dir(weights_dir)
|
|
379
399
|
return weights_path
|
|
380
400
|
# The model weights directory is empty, so we need to download the weights
|
|
381
401
|
except StopIteration:
|
|
382
402
|
pass
|
|
383
403
|
|
|
384
|
-
|
|
404
|
+
path = download_file(
|
|
385
405
|
url,
|
|
386
406
|
target_dir=weights_dir,
|
|
387
407
|
force=force,
|
|
388
408
|
request_headers=request_headers,
|
|
389
409
|
)
|
|
390
410
|
|
|
411
|
+
_mark_used_dir(weights_dir)
|
|
412
|
+
|
|
413
|
+
return path
|
|
414
|
+
|
|
391
415
|
|
|
392
416
|
def clone_repository(
|
|
393
417
|
https_url: str,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
fal/__init__.py,sha256=wXs1G0gSc7ZK60-bHe-B2m0l_sA6TrFk4BxY0tMoLe8,784
|
|
2
2
|
fal/__main__.py,sha256=4JMK66Wj4uLZTKbF-sT3LAxOsr6buig77PmOkJCRRxw,83
|
|
3
|
-
fal/_fal_version.py,sha256=
|
|
3
|
+
fal/_fal_version.py,sha256=3iEnYoHxc4pb1GpjK8VvmamtxkSp2aFPQ3We7nMxWMQ,513
|
|
4
4
|
fal/_serialization.py,sha256=npXNsFJ5G7jzBeBIyVMH01Ww34mGY4XWhHpRbSrTtnQ,7598
|
|
5
5
|
fal/_version.py,sha256=1BbTFnucNC_6ldKJ_ZoC722_UkW4S9aDBSW9L0fkKAw,2315
|
|
6
6
|
fal/api.py,sha256=wIEt21P1C7U-dYQEcyHUxxuuTnvzFyTpWDoHoaxq7tg,47385
|
|
@@ -59,14 +59,14 @@ fal/toolkit/types.py,sha256=kkbOsDKj1qPGb1UARTBp7yuJ5JUuyy7XQurYUBCdti8,4064
|
|
|
59
59
|
fal/toolkit/audio/__init__.py,sha256=sqNVfrKbppWlIGLoFTaaNTxLpVXsFHxOSHLA5VG547A,35
|
|
60
60
|
fal/toolkit/audio/audio.py,sha256=gt458h989iQ-EhQSH-mCuJuPBY4RneLJE05f_QWU1E0,572
|
|
61
61
|
fal/toolkit/file/__init__.py,sha256=FbNl6wD-P0aSSTUwzHt4HujBXrbC3ABmaigPQA4hRfg,70
|
|
62
|
-
fal/toolkit/file/file.py,sha256=
|
|
62
|
+
fal/toolkit/file/file.py,sha256=wDKK91i_1NJD5GGVSJPhFQ8C2FgxG2bJUnUexpHTjt8,10782
|
|
63
63
|
fal/toolkit/file/types.py,sha256=MMAH_AyLOhowQPesOv1V25wB4qgbJ3vYNlnTPbdSv1M,2304
|
|
64
64
|
fal/toolkit/file/providers/fal.py,sha256=Ph8v3Cm_eFu1b1AXiPKZQ5r8AWUALD3Wk18uw3z8RDQ,46910
|
|
65
65
|
fal/toolkit/file/providers/gcp.py,sha256=DKeZpm1MjwbvEsYvkdXUtuLIJDr_UNbqXj_Mfv3NTeo,2437
|
|
66
66
|
fal/toolkit/file/providers/r2.py,sha256=YqnYkkAo_ZKIa-xoSuDnnidUFwJWHdziAR34PE6irdI,3061
|
|
67
67
|
fal/toolkit/file/providers/s3.py,sha256=EI45T54Mox7lHZKROss_O8o0DIn3CHP9k1iaNYVrxvg,2714
|
|
68
68
|
fal/toolkit/image/__init__.py,sha256=m3OatPbBhcEOYyaTu_dgToxunUKoJu4bJVCWUoN7HX4,1838
|
|
69
|
-
fal/toolkit/image/image.py,sha256=
|
|
69
|
+
fal/toolkit/image/image.py,sha256=xmuIKU42DonGHnPS6V5MbLv-wBSlpVvfPTAy2A_Vds0,5614
|
|
70
70
|
fal/toolkit/image/safety_checker.py,sha256=S7ow-HuoVxC6ixHWWcBrAUm2dIlgq3sTAIull6xIbAg,3105
|
|
71
71
|
fal/toolkit/image/nsfw_filter/__init__.py,sha256=0d9D51EhcnJg8cZLYJjgvQJDZT74CfQu6mpvinRYRpA,216
|
|
72
72
|
fal/toolkit/image/nsfw_filter/env.py,sha256=iAP2Q3vzIl--DD8nr8o3o0goAwhExN2v0feYE0nIQjs,212
|
|
@@ -74,7 +74,7 @@ fal/toolkit/image/nsfw_filter/inference.py,sha256=BhIPF_zxRLetThQYxDDF0sdx9VRwvu
|
|
|
74
74
|
fal/toolkit/image/nsfw_filter/model.py,sha256=63mu8D15z_IosoRUagRLGHy6VbLqFmrG-yZqnu2vVm4,457
|
|
75
75
|
fal/toolkit/image/nsfw_filter/requirements.txt,sha256=3Pmrd0Ny6QAeBqUNHCgffRyfaCARAPJcfSCX5cRYpbM,37
|
|
76
76
|
fal/toolkit/utils/__init__.py,sha256=CrmM9DyCz5-SmcTzRSm5RaLgxy3kf0ZsSEN9uhnX2Xo,97
|
|
77
|
-
fal/toolkit/utils/download_utils.py,sha256=
|
|
77
|
+
fal/toolkit/utils/download_utils.py,sha256=F6oRoP2ynO5xgeRtweVpgJ5xmEhpbKorkXDrakaPpTw,21391
|
|
78
78
|
fal/toolkit/utils/endpoint.py,sha256=5EXoshA2PD_brjEfhNWAWasjqLOCRrjBnfhj6QGuMt8,782
|
|
79
79
|
fal/toolkit/utils/retry.py,sha256=0pnKqs1Y2dADMAk2944FZr68ZL3wQC_5hqApfgyMf_8,1531
|
|
80
80
|
fal/toolkit/video/__init__.py,sha256=YV0jWpuvoA_CDFQXhd3zOvilFLKH7DYARrbzR7hWhpE,35
|
|
@@ -142,8 +142,8 @@ openapi_fal_rest/models/workflow_node_type.py,sha256=-FzyeY2bxcNmizKbJI8joG7byRi
|
|
|
142
142
|
openapi_fal_rest/models/workflow_schema.py,sha256=4K5gsv9u9pxx2ItkffoyHeNjBBYf6ur5bN4m_zePZNY,2019
|
|
143
143
|
openapi_fal_rest/models/workflow_schema_input.py,sha256=2OkOXWHTNsCXHWS6EGDFzcJKkW5FIap-2gfO233EvZQ,1191
|
|
144
144
|
openapi_fal_rest/models/workflow_schema_output.py,sha256=EblwSPAGfWfYVWw_WSSaBzQVju296is9o28rMBAd0mc,1196
|
|
145
|
-
fal-1.
|
|
146
|
-
fal-1.
|
|
147
|
-
fal-1.
|
|
148
|
-
fal-1.
|
|
149
|
-
fal-1.
|
|
145
|
+
fal-1.27.1.dist-info/METADATA,sha256=TKeydxAK7aqE2EBQHAruwEtCBS11OjqDTQx_R3PQNW0,4089
|
|
146
|
+
fal-1.27.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
147
|
+
fal-1.27.1.dist-info/entry_points.txt,sha256=32zwTUC1U1E7nSTIGCoANQOQ3I7-qHG5wI6gsVz5pNU,37
|
|
148
|
+
fal-1.27.1.dist-info/top_level.txt,sha256=r257X1L57oJL8_lM0tRrfGuXFwm66i1huwQygbpLmHw,21
|
|
149
|
+
fal-1.27.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|