-
Notifications
You must be signed in to change notification settings - Fork 8
Fix for compatibility with Kedro 0.18.4 onwards #22
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,9 @@ | |
| from functools import cached_property | ||
| from typing import Any, List, MutableMapping, Optional, Union | ||
|
|
||
| import kedro | ||
| from kedro.framework.session import KedroSession | ||
| from packaging import version | ||
|
|
||
| from kedro_sagemaker.config import KedroSageMakerPluginConfig | ||
| from kedro_sagemaker.constants import ( | ||
|
|
@@ -67,9 +69,18 @@ def __init__( | |
|
|
||
| @cached_property | ||
| def plugin_config(self) -> KedroSageMakerPluginConfig: | ||
| return KedroSageMakerPluginConfig.parse_obj( | ||
| self.context.config_loader.get("sagemaker*") | ||
| ) | ||
| # from this version onwards (not inclusive) config_loader uses OmegaConfigLoader which requires a different syntax | ||
| required_version = version.parse("0.18.4") | ||
| current_version = version.parse(kedro.__version__) | ||
|
|
||
| if current_version > required_version: | ||
| return KedroSageMakerPluginConfig.parse_obj( | ||
| self.context.config_loader["parameters"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please clarify how this should work? If I understand correctly, the SageMaker configuration is stored in the self.config_patterns = {
"catalog": ["catalog*", "catalog*/**", "**/catalog*"],
"parameters": ["parameters*", "parameters*/**", "**/parameters*"],
"credentials": ["credentials*", "credentials*/**", "**/credentials*"],
"globals": ["globals.yml"],
}
Even if it were loaded along with other parameters, Pydantic would raise a validation error during the parsing process. |
||
| ) | ||
| else: | ||
| return KedroSageMakerPluginConfig.parse_obj( | ||
| self.context.config_loader.get("parameters*") | ||
| ) | ||
|
|
||
| @cached_property | ||
| def context(self): | ||
|
|
@@ -147,14 +158,18 @@ def nested_defaultdict(): | |
| return params | ||
|
|
||
|
|
||
| def docker_build(path: str, image: str) -> int: | ||
| def docker_build(path: str, image: str, platforms: str) -> int: | ||
| rv = subprocess.run( | ||
| [ | ||
| "docker", | ||
| "buildx", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buildx build? |
||
| "build", | ||
| "--platform", | ||
|
Lasica marked this conversation as resolved.
|
||
| platforms, | ||
| path, | ||
| "-t", | ||
| image, | ||
| "--push" | ||
| ], | ||
| stdout=sys.stdout, | ||
| stderr=subprocess.STDOUT, | ||
|
|
||
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.
You might want to use
importlib.metadatainstead of relying onpackaging.versionandkedro.__version__https://docs.python.org/3.9/library/importlib.metadata.html#metadataThere 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.
Sure happy to make that change. What is the benefit of doing it that way rather than using packaging.version?
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.
Using
packaging.versionmight be unavoidable if you want to parse it. The key is how to obtain the currently installed version, andimportlib.metadatais the canonical way I'd say. See pallets/flask#5230