Skip to content

Commit

Permalink
hotfix:make airtable conn work (#1554)
Browse files Browse the repository at this point in the history
  • Loading branch information
DhanshreeA authored Feb 18, 2025
1 parent 8ee31b6 commit 3b2bcc6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 46 deletions.
62 changes: 19 additions & 43 deletions ersilia/hub/content/base_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
InputBaseInformationError,
InputShapeBaseInformationError,
LicenseBaseInformationError,
ModeBaseInformationError,
OutputBaseInformationError,
OutputConsistencyBaseInformationError,
OutputDimensionBaseInformationError,
Expand Down Expand Up @@ -83,8 +82,6 @@ def __init__(self, config_json=None):
Placeholder for the model’s title.
_description : None
Placeholder for a description of the model.
_mode : None
Placeholder for the training mode, one of 'retrained', 'pretrained', 'in-house', or 'online'.
_task : None
Placeholder for the primary task associated with the model, such as 'classification', or 'regression'.
_subtask : None
Expand Down Expand Up @@ -151,7 +148,6 @@ def __init__(self, config_json=None):
self._status = None
self._title = None
self._description = None
self._mode = None
self._task = None
self._subtask = None
self._input = None
Expand Down Expand Up @@ -360,37 +356,6 @@ def description(self, new_description):
raise DescriptionBaseInformationError
self._description = new_description

@property
def mode(self):
"""
Get the model mode.
Returns
-------
str
The model mode.
"""
return self._mode

@mode.setter
def mode(self, new_mode):
"""
Set the model mode.
Parameters
----------
new_mode : str
The new model mode.
Raises
------
ModeBaseInformationError
If the mode is not valid.
"""
if new_mode not in self._read_default_fields("Mode"):
raise ModeBaseInformationError
self._mode = new_mode

@property
def source(self):
"""
Expand Down Expand Up @@ -983,7 +948,10 @@ def publication_year(self, new_publication_year):
"""
if type(new_publication_year) is not int:
raise PublicationYearBaseInformationError
if new_publication_year < 1900 or new_publication_year > datetime.today("Y"):
if (
new_publication_year < 1900
or new_publication_year > datetime.date.today().year
):
raise PublicationBaseInformationError
self._publication_year = new_publication_year

Expand Down Expand Up @@ -1265,7 +1233,9 @@ def environment_size(self, new_environment_size):
EnvironmentSizeMbBaseInformationError
If the environment size value is not valid.
"""
if not isinstance(new_environment_size, (int, float)):
if not new_environment_size:
new_environment_size = 0
elif not isinstance(new_environment_size, (int, float)):
raise EnvironmentSizeMbBaseInformationError
self._environment_size_mb = new_environment_size

Expand Down Expand Up @@ -1294,7 +1264,9 @@ def image_size_mb(self, new_image_size_mb):
ImageSizeMbBaseInformationError
If `new_image_size_mb` is not an integer.
"""
if not isinstance(new_image_size_mb, (int, float)):
if not new_image_size_mb:
new_image_size_mb = 0
elif not isinstance(new_image_size_mb, (int, float)):
raise ImageSizeMbBaseInformationError
self._image_size_mb = new_image_size_mb

Expand Down Expand Up @@ -1323,7 +1295,9 @@ def computational_performance_one(self, new_value):
ComputationalPerformanceOneBaseInformationError
If `new_value` is not an int or float.
"""
if not isinstance(new_value, (int, float)):
if not new_value:
new_value = 0
elif not isinstance(new_value, (int, float)):
raise ComputationalPerformanceOneBaseInformationError
self._computational_performance_one = new_value

Expand Down Expand Up @@ -1352,7 +1326,9 @@ def computational_performance_ten(self, new_value):
ComputationalPerformanceTenBaseInformationError
If `new_value` is not an int or float.
"""
if not isinstance(new_value, (int, float)):
if not new_value:
new_value = 0
elif not isinstance(new_value, (int, float)):
raise ComputationalPerformanceTenBaseInformationError
self._computational_performance_ten = new_value

Expand Down Expand Up @@ -1381,7 +1357,9 @@ def computational_performance_hund(self, new_value):
ComputationalPerformanceHundredBaseInformationError
If `new_value` is not an int or float.
"""
if not isinstance(new_value, (int, float)):
if not new_value:
new_value = 0
elif not isinstance(new_value, (int, float)):
raise ComputationalPerformanceHundredBaseInformationError
self._computational_performance_hund = new_value

Expand All @@ -1400,7 +1378,6 @@ def as_dict(self):
"Status": self.status,
"Title": self.title,
"Description": self.description,
"Mode": self.mode,
"Source": self.source,
"Source Type": self.source_type,
"Input": self.input,
Expand Down Expand Up @@ -1451,7 +1428,6 @@ def from_dict(self, data):
self._assign("status", "Status", data)
self._assign("title", "Title", data)
self._assign("description", "Description", data)
self._assign("mode", "Mode", data)
self._assign("source", "Source", data)
self._assign("source_type", "Source Type", data)
self._assign("input", "Input", data)
Expand Down
4 changes: 3 additions & 1 deletion ersilia/hub/content/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class RepoMetadataFile(ErsiliaBase):
def __init__(self, model_id=None, config_json=None):
self.model_id = model_id
ErsiliaBase.__init__(self, config_json=config_json, credentials_json=None)
self.is_json = False

def _github_json_url(self, org=None, branch=None):
if org is None:
Expand Down Expand Up @@ -73,6 +74,7 @@ def _get_file_content_from_github(self, org, branch):
else:
return yaml.safe_load(r.content)
else:
self.is_json = True
return json.loads(r.content)

def get_json_or_yaml_file(self, org: str = None, branch: str = None) -> dict:
Expand Down Expand Up @@ -154,7 +156,7 @@ def write_information(
path = json_or_yaml_path
with open(path, "w") as f:
json.dump(data, f, indent=4)
elif json_or_yaml_path.endswith(".yaml"):
elif json_or_yaml_path.endswith(".yml"):
path = json_or_yaml_path
with open(path, "w") as f:
yaml.dump(data, f)
Expand Down
3 changes: 2 additions & 1 deletion ersilia/hub/content/metadata/biomedical_area.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ADMET
Malaria
Tuberculosis
Tuberculosis
Any
4 changes: 3 additions & 1 deletion ersilia/hub/content/metadata/target_organism.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Human
Plasmodium spp.
Mycobacterium tuberculosis
Mycobacterium tuberculosis
Plasmodium falciparum
Not Applicable

0 comments on commit 3b2bcc6

Please sign in to comment.