This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b833561
commit c724d94
Showing
48 changed files
with
1,157 additions
and
305 deletions.
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 |
---|---|---|
@@ -1,15 +1,31 @@ | ||
""" | ||
Contains all errors used in Aztk. | ||
All error should inherit from `AztkError` | ||
""" | ||
|
||
|
||
|
||
class AztkError(Exception): | ||
def __init__(self, message: str = None): | ||
super().__init__() | ||
self.message = message | ||
super().__init__(message) | ||
|
||
class ClusterNotReadyError(AztkError): | ||
pass | ||
|
||
class AzureApiInitError(AztkError): | ||
def __init__(self, message: str = None): | ||
super().__init__() | ||
self.message = message | ||
pass | ||
|
||
class InvalidPluginConfigurationError(AztkError): | ||
pass | ||
|
||
class InvalidModelError(AztkError): | ||
pass | ||
|
||
class MissingRequiredAttributeError(InvalidModelError): | ||
pass | ||
|
||
class InvalidCustomScriptError(InvalidModelError): | ||
pass | ||
|
||
class InvalidPluginReferenceError(InvalidModelError): | ||
pass |
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,5 @@ | ||
""" | ||
Module containing classes used in the library but without any use for SDK user | ||
""" | ||
|
||
from .configuration_base import * |
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,42 @@ | ||
import yaml | ||
from aztk.error import AztkError | ||
|
||
class ConfigurationBase: | ||
""" | ||
Base class for any configuration. | ||
Include methods to help with validation | ||
""" | ||
|
||
@classmethod | ||
def from_dict(cls, args: dict): | ||
""" | ||
Create a new model from a dict values | ||
The dict is cleaned from null values and passed expanded to the constructor | ||
""" | ||
try: | ||
clean = dict((k, v) for k, v in args.items() if v) | ||
return cls(**clean) | ||
except TypeError as e: | ||
pretty_args = yaml.dump(args, default_flow_style=False) | ||
raise AztkError("{0} {1}\n{2}".format(cls.__name__, str(e), pretty_args)) | ||
|
||
def validate(self): | ||
raise NotImplementedError("Validate not implemented") | ||
|
||
def valid(self): | ||
try: | ||
self.validate() | ||
return True | ||
except AztkError: | ||
return False | ||
|
||
def _validate_required(self, attrs): | ||
for attr in attrs: | ||
if not getattr(self, attr): | ||
raise AztkError("{0} missing {1}.".format(self.__class__.__name__, attr)) | ||
|
||
def _merge_attributes(self, other, attrs): | ||
for attr in attrs: | ||
val = getattr(other, attr) | ||
if val is not None: | ||
setattr(self, attr, val) |
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 @@ | ||
from .models import * |
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,2 @@ | ||
from .plugin_file import * | ||
from .plugin_configuration import * |
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,2 @@ | ||
from .plugin_manager import * | ||
from .plugin_reference import * |
Oops, something went wrong.