-
Notifications
You must be signed in to change notification settings - Fork 1
AML-6 model manifest, tamper detection implementation #7
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
17815d1
initial commit, updated example to spec
zeryx 32576e4
created functional model_manifest workflow
zeryx 3b20ccf
added tests and fixed some parts of the manifest system
zeryx ada7f9c
added lock file tamper detection
zeryx 5a295f9
updated arity checking for both load and apply functions; if a load f…
zeryx bd99599
refactored and renamed manifest terms, added some basic testing and OOP
zeryx 10b9701
renamed lock to freeze, adjusted architecture of model data service
zeryx ec9c0fb
renamed internal variable and fixed error message
zeryx c68b0fe
updated freeze file and readme
zeryx 0818abe
updated examples and readme files with new modelData system
zeryx 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 hidden or 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 hidden or 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 hidden or 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,64 @@ | ||
import traceback | ||
import six | ||
import base64 | ||
import json | ||
|
||
|
||
def format_data(request): | ||
if request["content_type"] in ["text", "json"]: | ||
data = request["data"] | ||
elif request["content_type"] == "binary": | ||
data = wrap_binary_data(base64.b64decode(request["data"])) | ||
else: | ||
raise Exception("Invalid content_type: {}".format(request["content_type"])) | ||
return data | ||
|
||
|
||
def is_binary(arg): | ||
if six.PY3: | ||
return isinstance(arg, base64.bytes_types) | ||
|
||
return isinstance(arg, bytearray) | ||
|
||
|
||
def wrap_binary_data(data): | ||
if six.PY3: | ||
return bytes(data) | ||
else: | ||
return bytearray(data) | ||
|
||
|
||
def format_response(response): | ||
if is_binary(response): | ||
content_type = "binary" | ||
response = str(base64.b64encode(response), "utf-8") | ||
elif isinstance(response, six.string_types) or isinstance(response, six.text_type): | ||
content_type = "text" | ||
else: | ||
content_type = "json" | ||
response_string = json.dumps( | ||
{ | ||
"result": response, | ||
"metadata": { | ||
"content_type": content_type | ||
} | ||
} | ||
) | ||
return response_string | ||
|
||
|
||
def create_exception(exception, loading_exception=False): | ||
if hasattr(exception, "error_type"): | ||
error_type = exception.error_type | ||
elif loading_exception: | ||
error_type = "LoadingError" | ||
else: | ||
error_type = "AlgorithmError" | ||
response = json.dumps({ | ||
"error": { | ||
"message": str(exception), | ||
"stacktrace": traceback.format_exc(), | ||
"error_type": error_type, | ||
} | ||
}) | ||
return response |
Empty file.
This file contains hidden or 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,6 @@ | ||
|
||
class FileData(object): | ||
def __init__(self, md5_checksum, file_path): | ||
self.md5_checksum = md5_checksum | ||
self.file_path = file_path | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.