Skip to content

Commit dd3bd5c

Browse files
committed
Fix unit tests
1 parent 11da60b commit dd3bd5c

File tree

16 files changed

+51
-109
lines changed

16 files changed

+51
-109
lines changed

src/zenml/deployers/server/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ class BaseDeploymentInvocationRequest(BaseModel):
6060
timeout: int = Field(
6161
default=300, title="The timeout for the pipeline execution."
6262
)
63-
use_in_memory: bool = Field(
63+
skip_artifact_materialization: bool = Field(
6464
default=False,
65-
title="Whether to keep outputs in memory for fast access.",
65+
title="Whether to keep outputs in memory for fast access instead of "
66+
"storing them as artifacts.",
6667
)
6768

6869

src/zenml/deployers/server/service.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def execute_pipeline(
208208
placeholder_run=placeholder_run,
209209
deployment_snapshot=deployment_snapshot,
210210
resolved_params=parameters,
211-
use_in_memory=request.use_in_memory,
211+
skip_artifact_materialization=request.skip_artifact_materialization,
212212
)
213213

214214
# Map outputs using fast (in-memory) or slow (artifact) path
@@ -370,7 +370,7 @@ def _execute_with_orchestrator(
370370
placeholder_run: PipelineRunResponse,
371371
deployment_snapshot: PipelineSnapshotResponse,
372372
resolved_params: Dict[str, Any],
373-
use_in_memory: bool,
373+
skip_artifact_materialization: bool,
374374
) -> Optional[Dict[str, Dict[str, Any]]]:
375375
"""Run the snapshot via the orchestrator and return the concrete run.
376376
@@ -379,7 +379,8 @@ def _execute_with_orchestrator(
379379
deployment_snapshot: The deployment snapshot to execute the pipeline
380380
on.
381381
resolved_params: Normalized pipeline parameters.
382-
use_in_memory: Whether runtime should capture in-memory outputs.
382+
skip_artifact_materialization: Whether runtime should skip artifact
383+
materialization.
383384
384385
Returns:
385386
The in-memory outputs of the execution.
@@ -400,7 +401,7 @@ def _execute_with_orchestrator(
400401
request_id=str(uuid4()),
401402
snapshot=deployment_snapshot,
402403
parameters=resolved_params,
403-
skip_artifact_materialization=use_in_memory,
404+
skip_artifact_materialization=skip_artifact_materialization,
404405
)
405406

406407
captured_outputs: Optional[Dict[str, Dict[str, Any]]] = None

src/zenml/hooks/hook_validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Union,
2323
)
2424

25-
from pydantic import ConfigDict, PydanticSchemaGenerationError, ValidationError
25+
from pydantic import ConfigDict, ValidationError
2626

2727
from zenml.config.source import Source
2828
from zenml.exceptions import HookValidationException
@@ -69,7 +69,7 @@ def resolve_and_validate_hook(
6969

7070
# Validate hook arguments
7171
try:
72-
hook_args = ()
72+
hook_args: Tuple[Any, ...] = ()
7373
if allow_exception_arg:
7474
hook_args = (Exception(),)
7575
hook_kwargs = hook_kwargs or {}

src/zenml/steps/step_context.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ def get_step_context() -> "StepContext":
6262

6363

6464
def get_or_create_run_context() -> "RunContext":
65-
"""Get the context of the currently running pipeline.
65+
"""Get or create the context of the currently running pipeline.
6666
6767
Returns:
6868
The context of the currently running pipeline.
6969
"""
70-
if RunContext._exists():
71-
return RunContext()
7270
return RunContext()
7371

7472

tests/integration/functional/deployers/serving/conftest.py renamed to tests/integration/functional/deployers/server/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
# or implied. See the License for the specific language governing
1313
# permissions and limitations under the License.
14-
"""Test-specific fixtures for serving integration tests."""
14+
"""Test-specific fixtures for deployment integration tests."""
1515

1616
from types import SimpleNamespace
1717
from typing import Generator, Tuple

tests/integration/functional/deployers/serving/test_app_endpoints.py renamed to tests/integration/functional/deployers/server/test_app_endpoints.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
# or implied. See the License for the specific language governing
1313
# permissions and limitations under the License.
14-
"""Integration tests for FastAPI serving application endpoints."""
14+
"""Integration tests for FastAPI deployment application endpoints."""
1515

1616
import importlib
1717
from types import ModuleType, SimpleNamespace
@@ -22,7 +22,7 @@
2222
from fastapi.testclient import TestClient
2323
from pydantic import BaseModel
2424

25-
import zenml.deployers.server.app as serving_app
25+
import zenml.deployers.server.app as deployment_app
2626
from zenml.deployers.server.models import (
2727
BaseDeploymentInvocationRequest,
2828
BaseDeploymentInvocationResponse,
@@ -190,7 +190,7 @@ def client_service_pair(
190190
Yields:
191191
A tuple containing the FastAPI client, the stub service, and the reloaded app.
192192
"""
193-
reloaded_app = importlib.reload(serving_app)
193+
reloaded_app = importlib.reload(deployment_app)
194194
service = StubDeploymentService(str(uuid4()))
195195

196196
monkeypatch.setenv("ZENML_DEPLOYMENT_ID", str(service.deployment.id))
@@ -346,7 +346,7 @@ def test_cleanup_called_on_shutdown(
346346
],
347347
) -> None:
348348
"""Trigger service cleanup when the application shuts down."""
349-
reloaded_app = importlib.reload(serving_app)
349+
reloaded_app = importlib.reload(deployment_app)
350350
service = StubDeploymentService(str(uuid4()))
351351
monkeypatch.setenv("ZENML_DEPLOYMENT_ID", str(service.deployment.id))
352352
monkeypatch.setattr(

tests/unit/deployers/server/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
# or implied. See the License for the specific language governing
1313
# permissions and limitations under the License.
14-
"""Unit tests for serving functionality."""
14+
"""Unit tests for deployment functionality."""

tests/unit/deployers/server/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Test-specific fixtures for serving unit tests."""
1+
"""Test-specific fixtures for deployment unit tests."""
22

33
from types import SimpleNamespace
44
from typing import Iterator, Tuple

tests/unit/deployers/server/test_app.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
# or implied. See the License for the specific language governing
1313
# permissions and limitations under the License.
14-
"""Unit tests for serving app functionality."""
14+
"""Unit tests for deployment app functionality."""
1515

1616
from __future__ import annotations
1717

@@ -57,7 +57,7 @@ class MockWeatherRequest(BaseModel):
5757

5858
@pytest.fixture
5959
def mock_service(mocker: MockerFixture) -> PipelineDeploymentService:
60-
"""Mock pipeline serving service configured for the app tests."""
60+
"""Mock pipeline deployment service configured for the app tests."""
6161

6262
service = cast(
6363
PipelineDeploymentService,
@@ -114,7 +114,7 @@ def mock_service(mocker: MockerFixture) -> PipelineDeploymentService:
114114
return service
115115

116116

117-
class TestServingAppRoutes:
117+
class TestDeploymentAppRoutes:
118118
"""Test FastAPI app routes."""
119119

120120
def test_root_endpoint(
@@ -236,7 +236,7 @@ def test_get_pipeline_service_returns_current_instance(
236236
assert get_pipeline_service() is mock_service
237237

238238

239-
class TestServingAppInvoke:
239+
class TestDeploymentAppInvoke:
240240
"""Test pipeline invocation via FastAPI."""
241241

242242
def test_invoke_endpoint_executes_service(
@@ -255,7 +255,7 @@ def test_invoke_endpoint_executes_service(
255255
mock_service.execute_pipeline.assert_called_once()
256256
request_arg = mock_service.execute_pipeline.call_args.args[0]
257257
assert request_arg.parameters.city == "Paris"
258-
assert request_arg.use_in_memory is False
258+
assert request_arg.skip_artifact_materialization is False
259259

260260
def test_invoke_endpoint_validation_error(
261261
self, mock_service: PipelineDeploymentService
@@ -299,7 +299,7 @@ def test_verify_token_with_auth_disabled(
299299
assert verify_token(None) is None
300300

301301

302-
class TestServingAppLifecycle:
302+
class TestDeploymentAppLifecycle:
303303
"""Test app lifecycle management."""
304304

305305
def test_lifespan_test_mode(self, monkeypatch: pytest.MonkeyPatch) -> None:
@@ -358,7 +358,7 @@ async def _run() -> None:
358358
asyncio.run(_run())
359359

360360

361-
class TestServingAppErrorHandling:
361+
class TestDeploymentAppErrorHandling:
362362
"""Test app error handling."""
363363

364364
def test_value_error_handler(self) -> None:

tests/unit/deployers/server/test_parameter_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1212
# or implied. See the License for the specific language governing
1313
# permissions and limitations under the License.
14-
"""Comprehensive test for parameter resolution and flow in serving."""
14+
"""Comprehensive test for parameter resolution and flow in deployment."""
1515

1616
from unittest.mock import MagicMock
1717

@@ -24,7 +24,7 @@ class TestOutputRecording:
2424
"""Test output recording and retrieval functionality."""
2525

2626
@pytest.fixture(autouse=True)
27-
def setup_serving_state(self):
27+
def setup_deployment_state(self):
2828
"""Set up deployment state for each test."""
2929
runtime.stop()
3030
yield

0 commit comments

Comments
 (0)