-
Notifications
You must be signed in to change notification settings - Fork 18
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
Refactor metadata #126
Merged
Merged
Refactor metadata #126
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e725ddb
rework metadata
isabelizimm f767e80
add versions for required pkgs
isabelizimm adfe1aa
testing for all frameworks
isabelizimm 2713011
moving all metadata to base handler
isabelizimm 636b407
avoid torch import
isabelizimm 18752d1
avoid dependency errors
isabelizimm 90f2674
changes from review
isabelizimm 279a6c3
consolidate meta parsing
isabelizimm 72bdd85
use dataclass rather than dict
isabelizimm 38ac3e2
update pytorch test
isabelizimm 7a37a3d
handle required_pkgs in load_pkgs
isabelizimm 371428b
removing version from vetiver in attach_pkgs
isabelizimm 29ac30a
coerce VetiverMeta rather than try/except
isabelizimm 517a42c
remove version pinning from model pkgs
isabelizimm 1a3a796
update tests
isabelizimm f49cb35
install into docker from branch
isabelizimm da0e9ad
always install latest vetiver in docker
isabelizimm 982251e
refactoring docker test again
isabelizimm 748624e
merge conflicts
isabelizimm 2c83fa4
refactor metadata w prototypes
isabelizimm 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
def _model_meta( | ||
user: dict = None, version: str = None, url: str = None, required_pkgs: list = None | ||
): | ||
"""Populate relevant metadata for VetiverModel | ||
|
||
Args | ||
---- | ||
user: dict | ||
Extra user-defined information | ||
version: str | ||
Model version, generally populated from pins | ||
url: str | ||
Discoverable URL for API | ||
required_pkgs: list | ||
Packages necessary to make predictions | ||
""" | ||
meta = { | ||
"user": user, | ||
"version": version, | ||
"url": url, | ||
"required_pkgs": required_pkgs, | ||
} | ||
return meta | ||
from dataclasses import dataclass, asdict, field | ||
from typing import Mapping | ||
|
||
|
||
@dataclass | ||
class VetiverMeta: | ||
"""Metadata in a VetiverModel""" | ||
|
||
user: "dict | None" = field(default_factory=dict) | ||
version: "str | None" = None | ||
url: "str | None" = None | ||
required_pkgs: "list | None" = field(default_factory=list) | ||
|
||
def to_dict(self) -> Mapping: | ||
data = asdict(self) | ||
|
||
return data | ||
|
||
@classmethod | ||
def from_dict(cls, metadata, pip_name=None) -> "VetiverMeta": | ||
|
||
metadata = {} if metadata is None else metadata | ||
|
||
user = metadata.get("user", metadata) | ||
version = metadata.get("version", None) | ||
url = metadata.get("url", None) | ||
required_pkgs = metadata.get("required_pkgs", []) | ||
|
||
if pip_name: | ||
if not list(filter(lambda x: pip_name in x, required_pkgs)): | ||
required_pkgs = required_pkgs + [f"{pip_name}"] | ||
|
||
return cls(user, version, url, required_pkgs) |
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.
to handle the
pkg
weirdness, thepkg
attribute was removed. if there is a pip name, it will be handled as expected, otherwise it will set to None.