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

Fix RBAC in combination with lazy loaders #2869

Merged
merged 2 commits into from
Jul 22, 2024
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
2 changes: 2 additions & 0 deletions examples/e2e_nlp/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

settings:
docker:
python_package_installer: uv
install_stack_requirements: False
required_integrations:
- aws
- skypilot_aws
Expand Down
12 changes: 10 additions & 2 deletions src/zenml/zen_server/rbac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def dehydrate_response_model(
)

dehydrated_values = {}
for key, value in dict(model).items():
# See `get_subresources_for_model(...)` for a detailed explanation why we
# need to use `model.__iter__()` here
for key, value in model.__iter__():
dehydrated_values[key] = _dehydrate_value(
value, permissions=permissions
)
Expand Down Expand Up @@ -484,7 +486,13 @@ def get_subresources_for_model(
"""
resources = set()

for value in dict(model).values():
# We don't want to use `model.model_dump()` here as that recursively
# converts models to dicts, but we want to preserve those classes for
# the recursive `_get_subresources_for_value` calls.
# We previously used `dict(model)` here, but that lead to issues with
# models overwriting `__getattr__`, this `model.__iter__()` has the same
# results though.
for _, value in model.__iter__():
resources.update(_get_subresources_for_value(value))

return resources
Expand Down
3 changes: 2 additions & 1 deletion src/zenml/zen_server/routers/steps_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def create_run_step(
pipeline_run = zen_store().get_run(step.pipeline_run_id)
verify_permission_for_model(pipeline_run, action=Action.UPDATE)

return zen_store().create_run_step(step_run=step)
step = zen_store().create_run_step(step_run=step)
return dehydrate_response_model(step)


@router.get(
Expand Down