Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/service/studio_release_server/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def _write_dependency_manifest(
completed = subprocess.run(
[
sys.executable,
str(script),
"-m",
"veadk.cli.studio_dependencies",
"--manifest-only",
"--manifest",
str(destination),
Expand Down
17 changes: 13 additions & 4 deletions frontend/service/studio_release_server/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,19 @@ def _find_named(items: list[Any], name: str) -> Any | None:
def _find_function_id(service: Any) -> str:
from volcenginesdkvefaas import ListFunctionsRequest

response = service.client.list_functions(
ListFunctionsRequest(page_number=1, page_size=100)
)
function = _find_named(list(getattr(response, "items", []) or []), _FUNCTION_NAME)
page_number = 1
page_size = 100
functions: list[Any] = []
while True:
response = service.client.list_functions(
ListFunctionsRequest(page_number=page_number, page_size=page_size)
)
functions.extend(list(getattr(response, "items", []) or []))
total = int(getattr(response, "total", 0) or 0)
if page_number * page_size >= total:
break
page_number += 1
function = _find_named(functions, _FUNCTION_NAME)
return str(getattr(function, "id", "") or "")


Expand Down
2 changes: 1 addition & 1 deletion tests/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_vefaas_code_upload_callback_uses_configured_region() -> None:
url="https://example.com/upload",
data=b"archive",
headers={"Content-Type": "application/zip"},
timeout=(30, 300),
timeout=(300, 300),
)
callback.assert_called_once_with(
ak="test_access_key",
Expand Down
41 changes: 41 additions & 0 deletions tests/test_studio_release_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ def test_builder_restores_manifest_dependencies_from_cache(tmp_path: Path) -> No

def test_builder_generates_dependency_manifest_from_release_source(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
source_root = Path(__file__).parents[1]
prepared_root = tmp_path / ".studio-release"
Expand All @@ -709,6 +710,14 @@ def test_builder_generates_dependency_manifest_from_release_source(
_settings(),
dependency_store=dependency_store,
)
commands: list[list[str]] = []
original_run = subprocess.run

def capture_run(command: list[str], **kwargs: Any) -> subprocess.CompletedProcess:
commands.append(command)
return original_run(command, **kwargs)

monkeypatch.setattr(release_builder.subprocess, "run", capture_run)

wheels = builder._prepare_dependency_wheels(
source_root,
Expand All @@ -718,6 +727,11 @@ def test_builder_generates_dependency_manifest_from_release_source(
)

assert wheels == workspace / "dependency-wheels"
assert commands[0][:3] == [
sys.executable,
"-m",
"veadk.cli.studio_dependencies",
]
assert dependency_store.manifest == workspace / "dependencies.json"
assert json.loads(dependency_store.manifest.read_text(encoding="utf-8"))["wheels"]

Expand Down Expand Up @@ -836,6 +850,33 @@ def _install_runtime_wheels(*_args: Any, **_kwargs: Any) -> None:
).read_text(encoding="utf-8")


def test_function_lookup_paginates() -> None:
requested_pages: list[int] = []

class _Client:
def list_functions(self, request: Any) -> Any:
requested_pages.append(request.page_number)
if request.page_number == 1:
return SimpleNamespace(
total=101,
items=[SimpleNamespace(name="another-function", id="other-id")],
)
return SimpleNamespace(
total=101,
items=[
SimpleNamespace(
name="veadk-studio-release-server-fn",
id="release-function-id",
)
],
)

service = SimpleNamespace(client=_Client())

assert release_deploy._find_function_id(service) == "release-function-id"
assert requested_pages == [1, 2]


def test_set_github_secret_reads_value_from_stdin(
monkeypatch: pytest.MonkeyPatch,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion veadk/integrations/ve_faas/ve_faas.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _upload_and_mount_code(self, function_id: str, path: str):
url=upload_url,
data=code_zip_data,
headers=headers,
timeout=(30, 300),
timeout=(300, 300),
)
except requests.RequestException:
raise ValueError("Function code upload request failed.") from None
Expand Down
Loading