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

Artifact Version Table + Artifact Tagging #2081

Merged
merged 25 commits into from
Nov 30, 2023

Conversation

fa9r
Copy link
Contributor

@fa9r fa9r commented Nov 25, 2023

Describe changes

I split the artifact table into artifact and artifact_version so we can assign a separate set of tags to artifacts themselves.

Accordingly, I adjusted CLI, Client, models, ZenStores, and API endpoints to now have separate methods and representations for artifacts and artifact versions.

In particular, artifacts now support the following CLI commands:

zenml artifact update my_artifact -t add_this_tag -r remove_this_tag
zenml artifact version update my_artifact -v 1 -t add_this_tag -r remove_this_tag

Other changes:

  • zenml artifact prune now deletes all unused artifacts and artifact versions
  • zenml artifact delete was removed since deleting artifacts manually is too complex and error-prone to be exposed to users now

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • If my change requires a change to docs, I have updated the documentation accordingly.
  • If I have added an integration, I have updated the integrations table and the corresponding website section.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (add details above)

@github-actions github-actions bot added internal To filter out internal PRs and issues enhancement New feature or request labels Nov 25, 2023
@fa9r fa9r marked this pull request as ready for review November 27, 2023 16:55
src/zenml/cli/__init__.py Outdated Show resolved Hide resolved
src/zenml/cli/__init__.py Show resolved Hide resolved
docs/book/getting-started/core-concepts.md Outdated Show resolved Hide resolved
src/zenml/cli/artifact.py Show resolved Hide resolved
src/zenml/cli/artifact.py Show resolved Hide resolved
src/zenml/client.py Outdated Show resolved Hide resolved
src/zenml/models/v2/core/artifact_version.py Show resolved Hide resolved
src/zenml/models/v2/core/artifact_version.py Outdated Show resolved Hide resolved
src/zenml/zen_stores/schemas/tag_schemas.py Show resolved Hide resolved
src/zenml/zen_stores/zen_store_interface.py Outdated Show resolved Hide resolved
@fa9r fa9r requested a review from strickvl November 29, 2023 06:46
Copy link
Contributor

@strickvl strickvl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from my side, assuming tests pass.

Copy link
Contributor

@schustmi schustmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, there are a few changes we should make for RBAC to work:

  • Add a new ResourceType.ARTIFACT_VERSION
  • Update the create, update and delete endpoints for artifact versions to use this resource type
  • Update the read/list endpoints to use the parent artifact instead to verify whether someone can view a specific version
  • Update the functions get_surrogate_permission_model_for_model(...) and get_resource_type_for_model(...) in zenml.zen_server.rbac.utils.py to also handle artifact versions

src/zenml/zen_server/routers/workspaces_endpoints.py Outdated Show resolved Hide resolved
@fa9r fa9r requested a review from schustmi November 29, 2023 12:05
@fa9r fa9r requested a review from schustmi November 29, 2023 13:28
Copy link
Contributor

@schustmi schustmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RBAC part LGTM

Copy link
Contributor

@bcdurak bcdurak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes. The concepts of Models and Artifacts seem to be much more similar now. Left a few comments, hope it helps!

@@ -498,6 +503,7 @@ def get_resource_type_for_model(
SecretResponseModel: ResourceType.SECRET,
ModelResponseModel: ResourceType.MODEL,
ArtifactResponse: ResourceType.ARTIFACT,
ArtifactVersionResponse: ResourceType.ARTIFACT_VERSION,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, artifacts bear a lot of similarities to models in terms of their implementation. As model versions depend on models when it comes to RBAC, artifact versions also depend on artifacts.

Due to this, in the RBAC PR, model versions were left out of this mapping. Was there a different reason why we had to include them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/zenml/zen_server/zen_server_api.py Show resolved Hide resolved
ArtifactVisualizationRequest=ArtifactVisualizationRequest,
)
ArtifactResponseBody.update_forward_refs(
ArtifactVersionResponseBody.update_forward_refs(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArtifactVersionResponseBodys also have ArtifactResponses, right? I am surprised that this is not failing due to a forward reference issue.

Copy link
Contributor Author

@fa9r fa9r Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK a forward ref is only created if you specify your field type as a string, e.g.

class A(BaseModel):
    b: "OtherModel" = ...

However, in the artifact version we import the ArtifactResponse outside of type-checking and use the full type:

from zenml.models.v2.core.artifact import ArtifactResponse


class ArtifactVersionResponseBody(WorkspaceScopedResponseBody):
    artifact: ArtifactResponse = ...

So ArtifactVersionResponseBody.artifact should not be a forward ref if I understand it right.

Maybe @schustmi can confirm?

src/zenml/models/v2/core/artifact.py Show resolved Hide resolved
src/zenml/zen_server/routers/artifact_version_endpoints.py Outdated Show resolved Hide resolved
@@ -33,12 +33,12 @@


def link_step_artifacts_to_model(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this to link_step_artifact_versions_to_model as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do, no strong opinion against it

@@ -0,0 +1,228 @@
"""Artifact Version Table [a91762e6be36].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really recommend testing this against different scenarios as it is a significant migration IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed, so far I tested the following scenarios:

  • SQLite initialization from scratch
  • SQLite upgrade from 0.50.0 with existing artifacts
  • MySQL initialization from scratch
  • MySQL initialization from 0.50.0 with existing artifacts

Any other case I should test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I can't think of a different test.

However, In my experience, the migration failures mostly stem from (sort of) edge cases on various versions way before 0.50.0 or so. If there is such a case, (for instance where a specific field of the artifact can be possibly null), I would try to recreate this scenario and test that as well.

@bcdurak bcdurak mentioned this pull request Nov 29, 2023
9 tasks
@fa9r fa9r requested review from bcdurak and schustmi November 29, 2023 16:53
@fa9r fa9r merged commit ac0edbb into develop Nov 30, 2023
30 checks passed
@fa9r fa9r deleted the feature/OSS-2673-artifact-tagging branch November 30, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internal To filter out internal PRs and issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants