fal 1.28.0__py3-none-any.whl → 1.28.2__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 CHANGED
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '1.28.0'
21
- __version_tuple__ = version_tuple = (1, 28, 0)
31
+ __version__ = version = '1.28.2'
32
+ __version_tuple__ = version_tuple = (1, 28, 2)
33
+
34
+ __commit_id__ = commit_id = None
fal/api.py CHANGED
@@ -953,6 +953,11 @@ def function( # type: ignore
953
953
  ):
954
954
  if host is None:
955
955
  host = FalServerlessHost()
956
+
957
+ # NOTE: assuming kind="container" if image is provided
958
+ if config.get("image"):
959
+ kind = "container"
960
+
956
961
  options = host.parse_options(kind=kind, **config)
957
962
 
958
963
  def wrapper(func: Callable[ArgsT, ReturnT]):
fal/app.py CHANGED
@@ -411,28 +411,31 @@ class App(BaseServable):
411
411
  )
412
412
  return response
413
413
 
414
- @app.middleware("http")
415
- async def set_global_object_preference(request, call_next):
416
- try:
417
- preference_dict = request_lifecycle_preference(request)
418
- if preference_dict is not None:
419
- # This will not work properly for apps with multiplexing enabled
420
- # we may mix up the preferences between requests
421
- LIFECYCLE_PREFERENCE.set(preference_dict)
422
- except Exception:
423
- from fastapi.logger import logger
424
-
425
- logger.exception(
426
- "Failed set a global lifecycle preference %s",
427
- self.__class__.__name__,
428
- )
414
+ multiplexing = self.host_kwargs.get("max_multiplexing") or 1
415
+ if multiplexing == 1:
416
+ # just register the middleware if we are not multiplexing
417
+ @app.middleware("http")
418
+ async def set_global_object_preference(request, call_next):
419
+ try:
420
+ preference_dict = request_lifecycle_preference(request)
421
+ if preference_dict is not None:
422
+ # This will not work properly for apps with multiplexing enabled
423
+ # we may mix up the preferences between requests
424
+ LIFECYCLE_PREFERENCE.set(preference_dict)
425
+ except Exception:
426
+ from fastapi.logger import logger
427
+
428
+ logger.exception(
429
+ "Failed set a global lifecycle preference %s",
430
+ self.__class__.__name__,
431
+ )
429
432
 
430
- try:
431
- return await call_next(request)
432
- finally:
433
- # We may miss the global preference if there are operations
434
- # being done in the background that go beyond the request
435
- LIFECYCLE_PREFERENCE.set(None)
433
+ try:
434
+ return await call_next(request)
435
+ finally:
436
+ # We may miss the global preference if there are operations
437
+ # being done in the background that go beyond the request
438
+ LIFECYCLE_PREFERENCE.set(None)
436
439
 
437
440
  @app.middleware("http")
438
441
  async def set_request_id(request, call_next):
fal/toolkit/file/file.py CHANGED
@@ -84,15 +84,15 @@ def _try_with_fallback(
84
84
  fallback_save_kwargs: dict,
85
85
  ) -> Any:
86
86
  if fallback_repository is None:
87
- fallback_repositories = []
87
+ fallback_repository = []
88
88
  elif isinstance(fallback_repository, list):
89
- fallback_repositories = fallback_repository
89
+ pass
90
90
  else:
91
- fallback_repositories = [fallback_repository]
91
+ fallback_repository = [fallback_repository]
92
92
 
93
- attempts = [
93
+ attempts: list[tuple[FileRepository | RepositoryId, dict]] = [
94
94
  (repository, save_kwargs),
95
- *((fallback, fallback_save_kwargs) for fallback in fallback_repositories),
95
+ *((fallback, fallback_save_kwargs) for fallback in fallback_repository),
96
96
  ]
97
97
  for idx, (repo, kwargs) in enumerate(attempts):
98
98
  repo_obj = get_builtin_repository(repo)
@@ -201,9 +201,12 @@ class File(BaseModel):
201
201
 
202
202
  fdata = FileData(data, content_type, file_name)
203
203
 
204
- object_lifecycle_preference = (
205
- request_lifecycle_preference(request) or LIFECYCLE_PREFERENCE.get()
206
- )
204
+ if request:
205
+ object_lifecycle_preference = request_lifecycle_preference(request)
206
+ else:
207
+ print("[WARNING] No request provided, using global lifecycle preference")
208
+ object_lifecycle_preference = LIFECYCLE_PREFERENCE.get()
209
+
207
210
  save_kwargs.setdefault(
208
211
  "object_lifecycle_preference", object_lifecycle_preference
209
212
  )
@@ -250,9 +253,13 @@ class File(BaseModel):
250
253
  fallback_save_kwargs = fallback_save_kwargs or {}
251
254
 
252
255
  content_type = content_type or "application/octet-stream"
253
- object_lifecycle_preference = (
254
- request_lifecycle_preference(request) or LIFECYCLE_PREFERENCE.get()
255
- )
256
+
257
+ if request:
258
+ object_lifecycle_preference = request_lifecycle_preference(request)
259
+ else:
260
+ print("[WARNING] No request provided, using global lifecycle preference")
261
+ object_lifecycle_preference = LIFECYCLE_PREFERENCE.get()
262
+
256
263
  save_kwargs.setdefault(
257
264
  "object_lifecycle_preference", object_lifecycle_preference
258
265
  )
@@ -332,12 +339,9 @@ class CompressedFile(File):
332
339
  shutil.rmtree(self.extract_dir)
333
340
 
334
341
 
335
- def request_lifecycle_preference(request: Optional[Request]) -> dict[str, str] | None:
342
+ def request_lifecycle_preference(request: Request) -> dict[str, str] | None:
336
343
  import json
337
344
 
338
- if request is None:
339
- return None
340
-
341
345
  preference_str = request.headers.get(OBJECT_LIFECYCLE_PREFERENCE_KEY)
342
346
  if preference_str is None:
343
347
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fal
3
- Version: 1.28.0
3
+ Version: 1.28.2
4
4
  Summary: fal is an easy-to-use Serverless Python Framework
5
5
  Author: Features & Labels <support@fal.ai>
6
6
  Requires-Python: >=3.8
@@ -1,10 +1,10 @@
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=KkKtQzahpNn1MOumR-OVlanJVQlIRakwQ5jYMesgfes,513
3
+ fal/_fal_version.py,sha256=nTwdjoxcXTX5Uf2SU_PSi40OB3G-_aJ3rimio5QdbAU,706
4
4
  fal/_serialization.py,sha256=npXNsFJ5G7jzBeBIyVMH01Ww34mGY4XWhHpRbSrTtnQ,7598
5
5
  fal/_version.py,sha256=1BbTFnucNC_6ldKJ_ZoC722_UkW4S9aDBSW9L0fkKAw,2315
6
- fal/api.py,sha256=wIEt21P1C7U-dYQEcyHUxxuuTnvzFyTpWDoHoaxq7tg,47385
7
- fal/app.py,sha256=3RDFV6JUiUk8b3WJanKQYA-kW74t5bqaNy8OYuUH5-Q,25491
6
+ fal/api.py,sha256=TWUpQICgsRO5aDdRP8A3sFI26P6QM93TobcW9M4E0lQ,47501
7
+ fal/app.py,sha256=LktoVpMj3CXR3WCnptakDUvFwOVWsCfstl8wVofovIA,25740
8
8
  fal/apps.py,sha256=pzCd2mrKl5J_4oVc40_pggvPtFahXBCdrZXWpnaEJVs,12130
9
9
  fal/config.py,sha256=1HRaOJFOAjB7fbQoEPCSH85gMvEEMIMPeupVWgrHVgU,3572
10
10
  fal/container.py,sha256=FTsa5hOW4ars-yV1lUoc0BNeIIvAZcpw7Ftyt3A4m_w,2000
@@ -59,7 +59,7 @@ 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=wDKK91i_1NJD5GGVSJPhFQ8C2FgxG2bJUnUexpHTjt8,10782
62
+ fal/toolkit/file/file.py,sha256=_KCKmtmBkBIKD_gFOZALV10dCtOFZTC9MQw2qmdeevw,11013
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
@@ -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.28.0.dist-info/METADATA,sha256=lUYj94o8l7NTWMfpA5tYrsKSK5UwCFzmbEFa2gVSWPE,4089
146
- fal-1.28.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
147
- fal-1.28.0.dist-info/entry_points.txt,sha256=32zwTUC1U1E7nSTIGCoANQOQ3I7-qHG5wI6gsVz5pNU,37
148
- fal-1.28.0.dist-info/top_level.txt,sha256=r257X1L57oJL8_lM0tRrfGuXFwm66i1huwQygbpLmHw,21
149
- fal-1.28.0.dist-info/RECORD,,
145
+ fal-1.28.2.dist-info/METADATA,sha256=PFDPOVKkSNsGasm8URJ9h6YTVSIED9Sko-Rp37h8mdo,4089
146
+ fal-1.28.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
147
+ fal-1.28.2.dist-info/entry_points.txt,sha256=32zwTUC1U1E7nSTIGCoANQOQ3I7-qHG5wI6gsVz5pNU,37
148
+ fal-1.28.2.dist-info/top_level.txt,sha256=r257X1L57oJL8_lM0tRrfGuXFwm66i1huwQygbpLmHw,21
149
+ fal-1.28.2.dist-info/RECORD,,
File without changes