Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port bugfixes from #2497 #3179

Merged
merged 15 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion .github/workflows/update-templates-to-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ jobs:
with:
python-version: ${{ inputs.python-version }}
ref-zenml: ${{ github.ref }}
ref-template: 2024.10.30 # Make sure it is aligned with ZENML_PROJECT_TEMPLATES from src/zenml/cli/base.py
ref-template: 2024.11.08 # Make sure it is aligned with ZENML_PROJECT_TEMPLATES from src/zenml/cli/base.py
- name: Clean-up
run: |
rm -rf ./local_checkout
Expand Down
2 changes: 1 addition & 1 deletion examples/llm_finetuning/.copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 2024.10.30
_commit: 2024.11.08
_src_path: gh:zenml-io/template-llm-finetuning
bf16: true
cuda_version: cuda11.8
Expand Down
2 changes: 1 addition & 1 deletion examples/llm_finetuning/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
zenml
torch>=2.2.0
datasets
datasets>=2.15
transformers
peft
bitsandbytes>=0.41.3
Expand Down
2 changes: 1 addition & 1 deletion examples/llm_finetuning/steps/log_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def log_metadata_from_step_artifact(

context = get_step_context()
metadata_dict: Dict[str, Any] = (
context.pipeline_run.steps[step_name].outputs[artifact_name].load()
context.pipeline_run.steps[step_name].outputs[artifact_name][0].load()
)

metadata = {artifact_name: metadata_dict}
Expand Down
2 changes: 1 addition & 1 deletion src/zenml/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def copier_github_url(self) -> str:
),
llm_finetuning=ZenMLProjectTemplateLocation(
github_url="zenml-io/template-llm-finetuning",
github_tag="2024.10.30", # Make sure it is aligned with .github/workflows/update-templates-to-examples.yml
github_tag="2024.11.08", # Make sure it is aligned with .github/workflows/update-templates-to-examples.yml
),
)

Expand Down
4 changes: 3 additions & 1 deletion src/zenml/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,9 @@ def delete_deployment(self, id_or_prefix: str) -> None:
Args:
id_or_prefix: The id or id prefix of the deployment.
"""
deployment = self.get_deployment(id_or_prefix=id_or_prefix)
deployment = self.get_deployment(
id_or_prefix=id_or_prefix, hydrate=False
)
self.zen_store.delete_deployment(deployment_id=deployment.id)

# ------------------------------ Run templates -----------------------------
Expand Down
70 changes: 70 additions & 0 deletions src/zenml/zen_server/routers/logs_endpoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright (c) ZenML GmbH 2024. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
"""Endpoint definitions for steps (and artifacts) of pipeline runs."""

from uuid import UUID

from fastapi import APIRouter, Security

from zenml.constants import (
API,
LOGS,
VERSION_1,
)
from zenml.models.v2.core.logs import LogsResponse
from zenml.zen_server.auth import AuthContext, authorize
from zenml.zen_server.exceptions import error_response
from zenml.zen_server.rbac.models import Action
from zenml.zen_server.rbac.utils import (
verify_permission_for_model,
)
from zenml.zen_server.utils import (
handle_exceptions,
zen_store,
)

router = APIRouter(
prefix=API + VERSION_1 + LOGS,
tags=["logs"],
responses={401: error_response, 403: error_response},
)


@router.get(
"/{logs_id}",
response_model=LogsResponse,
responses={401: error_response, 404: error_response, 422: error_response},
)
@handle_exceptions
def get_step_logs(
logs_id: UUID,
_: AuthContext = Security(authorize),
) -> LogsResponse:
"""Get the logs by ID.

Args:
logs_id: ID of the logs.

Returns:
The logs response.
"""
logs = zen_store().get_logs(logs_id=logs_id, hydrate=True)
if step_run_id := logs.step_run_id:
if isinstance(step_run_id, UUID):
step_run = zen_store().get_run_step(step_run_id)
else:
step_run = zen_store().get_run_step(UUID(step_run_id))
pipeline_run = zen_store().get_run(step_run.pipeline_run_id)
verify_permission_for_model(pipeline_run, action=Action.READ)
return logs
avishniakov marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions src/zenml/zen_server/zen_server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
devices_endpoints,
event_source_endpoints,
flavors_endpoints,
logs_endpoints,
model_versions_endpoints,
models_endpoints,
pipeline_builds_endpoints,
Expand Down Expand Up @@ -414,6 +415,7 @@ async def dashboard(request: Request) -> Any:
app.include_router(plugin_endpoints.plugin_router)
app.include_router(event_source_endpoints.event_source_router)
app.include_router(flavors_endpoints.router)
app.include_router(logs_endpoints.router)
app.include_router(models_endpoints.router)
app.include_router(model_versions_endpoints.router)
app.include_router(model_versions_endpoints.model_version_artifacts_router)
Expand Down
Loading