-
Notifications
You must be signed in to change notification settings - Fork 443
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
Force forward slashes when saving artifacts #2195
Force forward slashes when saving artifacts #2195
Conversation
Important Auto Review SkippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThe changes involve updates to several materializer modules within ZenML. These updates primarily focus on ensuring cross-platform compatibility by replacing backslashes with forward slashes in URIs and file paths. Additionally, a new assertion has been added to the testing module to validate URIs. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChat with CodeRabbit Bot (
|
@coderabbitai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yaml
Files selected for processing (1)
- src/zenml/artifacts/utils.py (1 hunks)
Files skipped from review due to trivial changes (1)
- src/zenml/artifacts/utils.py
Unfortunately that proved to be too simple: replacing the URI at that location would only result in replacing the base path, not the eventual join between the base path and the file name. This, unfortunately, required adding replaces at materializer level. I tested with a locally running |
Nice! This is potentially a breaking change, I think, specifically for anyone who already has an artifact saved that includes a backslash? |
Two more changes:
|
Not sure if breaking. Old pipeline runs with failing paths keep failing after applying this PR, only new ones are saved correctly. For example, this path was saved with the original PR contents (before adding backslash conversion to the materializers themselves); even though it is now working, the original path keeps failing, so strictly speaking no backwards incompatibility there:
If you'd like to correct these as well (which I'm not sure of) we'll probably need to add a database migration which applies backslash conversion to the paths of these artifacts / visualizations as well. |
@christianversloot no you're right. I think no need to retrospectively migrate / correct things that are still working. They're just saved in the DB using the 'incorrect' naming but they'd still be accessible etc as you say. |
@coderabbitai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yaml
Files selected for processing (9)
- src/zenml/artifacts/utils.py (2 hunks)
- src/zenml/integrations/deepchecks/materializers/deepchecks_results_materializer.py (1 hunks)
- src/zenml/integrations/facets/materializers/facets_materializer.py (1 hunks)
- src/zenml/integrations/pillow/materializers/pillow_image_materializer.py (1 hunks)
- src/zenml/integrations/whylogs/materializers/whylogs_materializer.py (1 hunks)
- src/zenml/materializers/numpy_materializer.py (1 hunks)
- src/zenml/materializers/pandas_materializer.py (1 hunks)
- src/zenml/materializers/structured_string_materializer.py (1 hunks)
- tests/unit/test_general.py (1 hunks)
Files skipped from review due to trivial changes (6)
- src/zenml/integrations/deepchecks/materializers/deepchecks_results_materializer.py
- src/zenml/integrations/facets/materializers/facets_materializer.py
- src/zenml/integrations/pillow/materializers/pillow_image_materializer.py
- src/zenml/integrations/whylogs/materializers/whylogs_materializer.py
- src/zenml/materializers/numpy_materializer.py
- src/zenml/materializers/structured_string_materializer.py
Additional comments: 3
tests/unit/test_general.py (1)
- 93-98: The addition of the assertion to ensure that the
uri
does not contain backslashes is a good practice for maintaining cross-platform compatibility of file paths. This change aligns with the PR's objective to handle URIs correctly on Windows systems.src/zenml/materializers/pandas_materializer.py (1)
- 144-150: The modification to replace backslashes with forward slashes in the
describe_uri
within thesave_visualizations
method is correct and ensures that the file paths are compatible across different operating systems. This change is in line with the PR's objective to fix path issues on Windows.src/zenml/artifacts/utils.py (1)
- 146-154: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [122-154]
The changes to the
save_artifact
function, which include forcing URIs to have forward slashes and updating the materializer object's URI, are correct and align with the PR's objective to ensure that URIs are handled properly on Windows systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and the test failures are known.
@christianversloot thanks for handling this! |
Describe changes
When saving visualizations into S3 artifact stores, Windows-based pipeline runs generate backward slash based URIs because that's how
os.path.join
works on Windows. An example would bes3://bucket\\visualize_principal_components\\output\\1a6d995d-1417-4c8c-89d0-99d0e5897d8e\\image_file.PNG
. Following that, loading the artifact from the artifact store fails because of a malformed key.This PR attempts fixing the issue by forcing all paths to have forward slashes when saving artifacts.
save_artifact
and when none are passed.Pre-requisites
Please ensure you have done the following:
develop
and the open PR is targetingdevelop
. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.Types of changes
Summary by CodeRabbit