-
Notifications
You must be signed in to change notification settings - Fork 905
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
Modularize default load and save argument handling #15
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b9bf25d
Modularize default load and save argument handling
deepyaman ba18548
Suppress ``super-init-not-called`` pylint messages
deepyaman 41b40b2
Copy default args to prevent accidental mutation
deepyaman c10a654
Restore ``super().__init__`` given default arg fix
deepyaman bf2643f
Merge branch 'develop' into fix/default-args
deepyaman e83502c
Refactor abstract base class modification as mixin
deepyaman 63fda57
Homogenize default load and save argument handling
deepyaman 0505773
Demarcate load and save argument handling :dragon:
deepyaman a93abf2
Cover load and save argument handling :paw_prints:
deepyaman 4226c2e
Add tests to cover load/save argument conditionals
deepyaman a17ae9e
Fix non-ASCII characters in legal header :pencil2:
deepyaman f7b2373
Remove load/save defaults from ``AbstractDataSet``
deepyaman 124d663
Call ``super().__init__`` in mix-in implementation
deepyaman d3c7153
Fix MRO when subclassing ``DefaultArgumentsMixIn``
deepyaman da10346
Merge branch 'fix/default-args' of https://github.com/deepyaman/kedro…
deepyaman cac0c78
Copy default argument dicts with ``copy.deepcopy``
deepyaman 681beb0
Merge branch 'develop' into fix/default-args
deepyaman 0d31b7c
Merge branch 'develop' of https://github.com/quantumblacklabs/kedro i…
deepyaman 473d725
Merge branch 'develop' into fix/default-args
deepyaman 2a575d6
Merge branch 'develop' into fix/default-args
deepyaman 5896daa
Annotate types for default load and save arguments
deepyaman 3931744
Revert "Annotate types for default load and save arguments"
deepyaman b2e4c1c
Annotate types for default load and save arguments
deepyaman 184d9f7
Merge branch 'develop' into fix/default-args
deepyaman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2018-2019 QuantumBlack Visual Analytics Limited | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND | ||
# NONINFRINGEMENT. IN NO EVENT WILL THE LICENSOR OR OTHER CONTRIBUTORS | ||
# BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN | ||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN | ||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
# The QuantumBlack Visual Analytics Limited ("QuantumBlack") name and logo | ||
# (either separately or in combination, "QuantumBlack Trademarks") are | ||
# trademarks of QuantumBlack. The License does not grant you any right or | ||
# license to the QuantumBlack Trademarks. You may not use the QuantumBlack | ||
# Trademarks or any confusingly similar mark as a trademark for your product, | ||
# or use the QuantumBlack Trademarks in any other manner that might cause | ||
# confusion in the marketplace, including but not limited to in advertising, | ||
# on websites, or on software. | ||
# | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""This module extends the set of classes ``kedro.io.core`` provides.""" | ||
|
||
import copy | ||
from typing import Any, Dict, Optional | ||
|
||
|
||
# pylint: disable=too-few-public-methods | ||
class DefaultArgumentsMixIn: | ||
"""Mixin class that helps handle default load and save arguments.""" | ||
|
||
DEFAULT_LOAD_ARGS = {} # type: Dict[str, Any] | ||
DEFAULT_SAVE_ARGS = {} # type: Dict[str, Any] | ||
|
||
def __init__( | ||
self, | ||
load_args: Optional[Dict[str, Any]] = None, | ||
save_args: Optional[Dict[str, Any]] = None, | ||
) -> None: | ||
super().__init__() | ||
self._load_args = copy.deepcopy(self.DEFAULT_LOAD_ARGS) | ||
if load_args is not None: | ||
self._load_args.update(load_args) | ||
self._save_args = copy.deepcopy(self.DEFAULT_SAVE_ARGS) | ||
if save_args is not None: | ||
self._save_args.update(save_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I prefer calling
super
at the top of the constructor, so the subclass would overwrite stuff from the parent, as a "specialisation" of the superclass.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.
Fair argument. I just left it in the same place where default arguments were previously handled (as close to the original as I could), but that makes sense.