Skip to content
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

added metatdata and check if serializable #18

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ dist/
build_package/
htmlcov/
.coverage
.pytest_cache
.pytest_cache
build/
*.egg-info/
3 changes: 2 additions & 1 deletion debiai/debiai_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ class Debiai_model:
A Debiai project model
"""

def __init__(self, project, name: str, id: str):
def __init__(self, project, name: str, id: str, metadata: dict = {}):
self.project = project
self.name = name
self.id = id
self.metadata = metadata

def expected_results_exists(self):
"""
Expand Down
8 changes: 7 additions & 1 deletion debiai/debiai_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import debiai_utils as debiai_utils
from .debiai_services.df_to_dict_tree import df_to_dict_tree
from .debiai_services.np_to_dict import check_np_array, np_to_dict
import json

DEBIAI_TYPES = ["contexts", "inputs", "groundTruth", "others"]

Expand Down Expand Up @@ -406,9 +407,14 @@ def create_model(self, name: str, metadata: dict = {}) -> Debiai_model:
if not name:
raise ValueError("Can't create the model: The model name is required")

try:
json.dumps(metadata)
except TypeError:
raise ValueError("The metadata dictionary is not JSON serializable")

# Call the backend
if utils.post_model(self.debiai_url, self.id, name, metadata):
return Debiai_model(self, name, name)
return Debiai_model(self, name, name, metadata)
else:
return False

Expand Down
Loading