Skip to content

Commit

Permalink
fix: use a setup function to the fal function that creates a patch ps…
Browse files Browse the repository at this point in the history
…eudo-package in a temp dir that is prepended to PATH
  • Loading branch information
lmmx committed Jan 29, 2024
1 parent d587c38 commit 7555737
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion projects/fal/tests/test_apps_simple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from pathlib import Path

import fal
import pytest
Expand Down Expand Up @@ -27,11 +28,27 @@ class Output(BaseModel):
result: int


pydantic_patch_contents = Path("pydantic_patch.py").read_text()


def test_fn():
import sys
from tempfile import mkdtemp

package_dir = mkdtemp()

path = Path(package_dir) / "pydantic_patch.py"
path.write_text(pydantic_patch_contents)

sys.path.insert(0, package_dir)


@fal.function(
keep_alive=60,
keep_alive=0,
machine_type="S",
serve=True,
max_concurrency=1,
setup_function=test_fn,
)
def addition_app(input: Input) -> Output:
print("starting...")
Expand Down

0 comments on commit 7555737

Please sign in to comment.