Skip to content

Commit

Permalink
Merge branch 'develop' into misc/rename-nlp-example
Browse files Browse the repository at this point in the history
  • Loading branch information
safoinme authored Jan 4, 2024
2 parents 6ead818 + 14fc0b8 commit 4c96c4c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 25 deletions.
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ general guidelines that cover both:
A friendly ping in the comment thread to the submitter or a contributor can help
draw attention if your issue is blocking.

### Good First Issues for New Contributors

The best way to start is to check the
[`good-first-issue`](https://github.com/zenml-io/zenml/labels/good%20first%20issue)
[`good-first-issue`](https://github.com/issues?q=is%3Aopen+is%3Aissue+archived%3Afalse+user%3Azenml-io+label%3A%22good+first+issue%22)
label on the issue board. The core team creates these issues as necessary
smaller tasks that you can work on to get deeper into ZenML internals. These
should generally require relatively simple changes, probably affecting just one
or two files which we think are ideal for people new to ZenML.

The next step after that would be to look at the
[`good-second-issue`](https://github.com/zenml-io/zenml/labels/good%20second%20issue)
[`good-second-issue`](https://github.com/issues?q=is%3Aopen+is%3Aissue+archived%3Afalse+user%3Azenml-io+label%3A%22good+second+issue%22)
label on the issue board. These are a bit more complex, might involve more
files, but should still be well-defined and achievable to people relatively new
to ZenML.
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
·
<a href="https://zenml.io/discussion">Vote New Features</a>
·
<a href="https://blog.zenml.io/">Read Blog</a>
<a href="https://www.zenml.io/blog">Read Blog</a>
·
<a href="https://github.com/issues?q=is%3Aopen+is%3Aissue+archived%3Afalse+user%3Azenml-io+label%3A%22good+first+issue%22">Contribute to Open Source</a>
·
<a href="https://www.zenml.io/company#team">Meet the Team</a>
<br />
Expand Down Expand Up @@ -277,9 +279,10 @@ and you can directly influence the roadmap as follows:

# 🙌 Contributing and Community

We would love to develop ZenML together with our community! Best way to get
We would love to develop ZenML together with our community! The best way to get
started is to select any issue from the [`good-first-issue`
label](https://github.com/zenml-io/zenml/labels/good%20first%20issue). If you
label](https://github.com/issues?q=is%3Aopen+is%3Aissue+archived%3Afalse+user%3Azenml-io+label%3A%22good+first+issue%22)
and open up a Pull Request! If you
would like to contribute, please review our [Contributing
Guide](CONTRIBUTING.md) for all relevant details.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ types-psutil = { version = "^5.8.13", optional = true }
types-passlib = { version = "^1.7.7", optional = true }

# mlstacks dependencies
mlstacks = { version = "0.7.11", optional = true }
mlstacks = { version = "0.8.0", optional = true }

[tool.poetry.extras]
server = [
Expand Down
2 changes: 2 additions & 0 deletions src/zenml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
save_artifact,
load_artifact,
)
from zenml.model.utils import log_model_metadata
from zenml.artifacts.artifact_config import ArtifactConfig
from zenml.artifacts.external_artifact import ExternalArtifact
from zenml.model.model_version import ModelVersion
Expand All @@ -57,6 +58,7 @@
"get_step_context",
"load_artifact",
"log_artifact_metadata",
"log_model_metadata",
"ModelVersion",
"pipeline",
"save_artifact",
Expand Down
27 changes: 27 additions & 0 deletions src/zenml/model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,33 @@ def log_model_version_metadata(
This function can be used to log metadata for existing model versions.
Args:
metadata: The metadata to log.
model_name: The name of the model to log metadata for. Can
be omitted when being called inside a step with configured
`model_version` in decorator.
model_version: The version of the model to log metadata for. Can
be omitted when being called inside a step with configured
`model_version` in decorator.
"""
logger.warning(
"`log_model_version_metadata` is deprecated. Please use "
"`log_model_metadata` instead."
)
log_model_metadata(
metadata=metadata, model_name=model_name, model_version=model_version
)


def log_model_metadata(
metadata: Dict[str, "MetadataType"],
model_name: Optional[str] = None,
model_version: Optional[Union[ModelStages, int, str]] = None,
) -> None:
"""Log model version metadata.
This function can be used to log metadata for existing model versions.
Args:
metadata: The metadata to log.
model_name: The name of the model to log metadata for. Can
Expand Down
7 changes: 1 addition & 6 deletions src/zenml/models/v2/base/scoped.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,10 @@ def apply_filter(
Returns:
The query with filter applied.
"""
from sqlmodel import or_

query = super().apply_filter(query=query, table=table)

if self.scope_user:
scope_filter = or_(
getattr(table, "user_id") == self.scope_user,
)
query = query.where(scope_filter)
query = query.where(getattr(table, "user_id") == self.scope_user)

return query

Expand Down
4 changes: 2 additions & 2 deletions src/zenml/zen_stores/schemas/component_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class StackComponentSchema(NamedSchema, table=True):
back_populates="stack_component",
)

run_or_step_logs: Optional["LogsSchema"] = Relationship(
run_or_step_logs: List["LogsSchema"] = Relationship(
back_populates="artifact_store",
sa_relationship_kwargs={"cascade": "delete", "uselist": False},
sa_relationship_kwargs={"cascade": "delete", "uselist": True},
)

connector_id: Optional[UUID] = build_foreign_key_field(
Expand Down
6 changes: 2 additions & 4 deletions src/zenml/zen_stores/schemas/pipeline_run_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ def to_model(self, hydrate: bool = False) -> "PipelineRunResponse":
}

if self.deployment is not None:
steps = {s.name: s.to_model() for s in self.step_runs}

deployment = self.deployment.to_model()

config = deployment.pipeline_configuration
Expand All @@ -237,8 +235,6 @@ def to_model(self, hydrate: bool = False) -> "PipelineRunResponse":
code_reference = deployment.code_reference

elif self.pipeline_configuration is not None:
steps = {step.name: step.to_model() for step in self.step_runs}

config = PipelineConfiguration.parse_raw(
self.pipeline_configuration
)
Expand Down Expand Up @@ -274,6 +270,8 @@ def to_model(self, hydrate: bool = False) -> "PipelineRunResponse":
)
metadata = None
if hydrate:
steps = {step.name: step.to_model() for step in self.step_runs}

metadata = PipelineRunResponseMetadata(
workspace=self.workspace.to_model(),
run_metadata=run_metadata,
Expand Down
5 changes: 3 additions & 2 deletions src/zenml/zen_stores/sql_zen_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5453,13 +5453,14 @@ def _update_pipeline_run_status(
)

if new_status != pipeline_run.status:
pipeline_run.status = new_status
run_update = PipelineRunUpdate(status=new_status)
if new_status in {
ExecutionStatus.COMPLETED,
ExecutionStatus.FAILED,
}:
pipeline_run.end_time = datetime.utcnow()
run_update.end_time = datetime.utcnow()

pipeline_run.update(run_update)
session.add(pipeline_run)

# ----------------------------- Users -----------------------------
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/functional/model/test_model_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from zenml.client import Client
from zenml.enums import ModelStages
from zenml.model.model_version import ModelVersion
from zenml.model.utils import log_model_version_metadata
from zenml.model.utils import log_model_metadata
from zenml.models import TagRequest

MODEL_NAME = "super_model"
Expand Down Expand Up @@ -64,7 +64,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
@step
def step_metadata_logging_functional():
"""Functional logging using implicit ModelVersion from context."""
log_model_version_metadata({"foo": "bar"})
log_model_metadata({"foo": "bar"})
assert get_step_context().model_version.metadata["foo"] == "bar"


Expand Down Expand Up @@ -357,17 +357,17 @@ def test_metadata_logging_functional(self, clean_client: "Client"):
)
mv._get_or_create_model_version()

log_model_version_metadata(
log_model_metadata(
{"foo": "bar"}, model_name=mv.name, model_version=mv.number
)

assert len(mv.metadata) == 1
assert mv.metadata["foo"] == "bar"

with pytest.raises(ValueError):
log_model_version_metadata({"foo": "bar"})
log_model_metadata({"foo": "bar"})

log_model_version_metadata(
log_model_metadata(
{"bar": "foo"}, model_name=mv.name, model_version="latest"
)

Expand Down

0 comments on commit 4c96c4c

Please sign in to comment.