fal 1.28.0__py3-none-any.whl → 1.28.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 CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.28.0'
21
- __version_tuple__ = version_tuple = (1, 28, 0)
20
+ __version__ = version = '1.28.1'
21
+ __version_tuple__ = version_tuple = (1, 28, 1)
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
@@ -201,9 +201,11 @@ 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
+ object_lifecycle_preference = LIFECYCLE_PREFERENCE.get()
208
+
207
209
  save_kwargs.setdefault(
208
210
  "object_lifecycle_preference", object_lifecycle_preference
209
211
  )
@@ -250,9 +252,12 @@ class File(BaseModel):
250
252
  fallback_save_kwargs = fallback_save_kwargs or {}
251
253
 
252
254
  content_type = content_type or "application/octet-stream"
253
- object_lifecycle_preference = (
254
- request_lifecycle_preference(request) or LIFECYCLE_PREFERENCE.get()
255
- )
255
+
256
+ if request:
257
+ object_lifecycle_preference = request_lifecycle_preference(request)
258
+ else:
259
+ object_lifecycle_preference = LIFECYCLE_PREFERENCE.get()
260
+
256
261
  save_kwargs.setdefault(
257
262
  "object_lifecycle_preference", object_lifecycle_preference
258
263
  )
@@ -332,12 +337,9 @@ class CompressedFile(File):
332
337
  shutil.rmtree(self.extract_dir)
333
338
 
334
339
 
335
- def request_lifecycle_preference(request: Optional[Request]) -> dict[str, str] | None:
340
+ def request_lifecycle_preference(request: Request) -> dict[str, str] | None:
336
341
  import json
337
342
 
338
- if request is None:
339
- return None
340
-
341
343
  preference_str = request.headers.get(OBJECT_LIFECYCLE_PREFERENCE_KEY)
342
344
  if preference_str is None:
343
345
  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.1
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=uuctUYGLYKZiRv4u5GjbkTTYV9QJ7oYdTxJCsNX-iN8,513
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=0VI8ZgGV3tnbDN6vlM8L8AHt5gul6-emuPLjVBB_vt0,10836
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.1.dist-info/METADATA,sha256=kcAdoePxY_Zy3_-5QOvvaS5P72vGwa-db_3p8WktQCU,4089
146
+ fal-1.28.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
147
+ fal-1.28.1.dist-info/entry_points.txt,sha256=32zwTUC1U1E7nSTIGCoANQOQ3I7-qHG5wI6gsVz5pNU,37
148
+ fal-1.28.1.dist-info/top_level.txt,sha256=r257X1L57oJL8_lM0tRrfGuXFwm66i1huwQygbpLmHw,21
149
+ fal-1.28.1.dist-info/RECORD,,
File without changes