From e896fd1ec06dedb93a5bdefd86bbc5e4cb36b7f1 Mon Sep 17 00:00:00 2001 From: Dhanshree Arora Date: Wed, 18 Dec 2024 01:27:36 +0530 Subject: [PATCH] Fix info endpoint, and update dockerfiles (#1461) --- .github/scripts/airtableops.py | 6 +++--- .../dockerize-ersiliapack/model/Dockerfile.conda | 7 +++++-- dockerfiles/dockerize-ersiliapack/model/Dockerfile.pip | 10 +++++++++- ersilia/hub/content/card.py | 2 +- ersilia/serve/services.py | 4 ++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/scripts/airtableops.py b/.github/scripts/airtableops.py index 6f5ec238..718b8e32 100644 --- a/.github/scripts/airtableops.py +++ b/.github/scripts/airtableops.py @@ -63,8 +63,8 @@ def items_all(self): class AirtableMetadata(AirtableInterface): def __init__(self, model_id, api_key=None, mode="ro"): + super().__init__(mode=mode, api_key=api_key) self.model_id = model_id - super().__init__(self, mode=mode, api_key=api_key) self._empty_row_message = "The AirTable field Identifier was not found! Please check that there are not empty rows." def _find_record(self): @@ -96,7 +96,7 @@ def _find_airtable_record_id(self): def read_information(self): data = self._find_record() - bi = BaseInformation(config_json=self.config_json) + bi = BaseInformation() bi.from_dict(data) return bi @@ -266,7 +266,7 @@ def update_metadata_to_airtable(user, repo, branch, api_key): # Works with airtable-update option rm = RepoMetadataFile(model_id=repo, config_json=None) data = rm.read_information(org=user, branch=branch) - am = AirtableMetadata(model_id=repo, config_json=None) + am = AirtableMetadata(model_id=repo, api_key=api_key, mode="rw") am.write_information(data) diff --git a/dockerfiles/dockerize-ersiliapack/model/Dockerfile.conda b/dockerfiles/dockerize-ersiliapack/model/Dockerfile.conda index 5224bdbe..74a9ba7a 100644 --- a/dockerfiles/dockerize-ersiliapack/model/Dockerfile.conda +++ b/dockerfiles/dockerize-ersiliapack/model/Dockerfile.conda @@ -3,7 +3,10 @@ ARG MODEL=eos_identifier ENV MODEL=$MODEL WORKDIR /root COPY ./$MODEL /root/$MODEL -RUN mkdir /root/bundles && ersilia_model_pack --repo_path $MODEL --bundles_repo_path /root/bundles +RUN apt-get update && \ + apt-get install -y git && \ + mkdir /root/bundles && ersilia_model_pack --repo_path $MODEL --bundles_repo_path /root/bundles && \ + apt-get remove --purge -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* RUN conda create --name baseclone --clone base RUN conda install -c conda-forge conda-pack RUN conda-pack -n baseclone -o /tmp/env.tar && \ @@ -28,7 +31,7 @@ ENV PATH="/usr/bin/conda/bin/:$PATH" COPY --from=build /root/bundles /root/bundles COPY --from=build /root/docker-entrypoint.sh /root/docker-entrypoint.sh COPY --from=build /venv /usr/bin/conda - +RUN conda install -c conda-forge xorg-libxrender xorg-libxtst RUN cp /root/bundles/$MODEL/*/information.json /root/information.json && \ cp /root/bundles/$MODEL/*/api_schema.json /root/api_schema.json && \ cp /root/bundles/$MODEL/*/status.json /root/status.json && \ diff --git a/dockerfiles/dockerize-ersiliapack/model/Dockerfile.pip b/dockerfiles/dockerize-ersiliapack/model/Dockerfile.pip index dbfdffaf..8b4a0027 100644 --- a/dockerfiles/dockerize-ersiliapack/model/Dockerfile.pip +++ b/dockerfiles/dockerize-ersiliapack/model/Dockerfile.pip @@ -3,7 +3,15 @@ ARG MODEL=eos_identifier ENV MODEL=$MODEL WORKDIR /root COPY ./$MODEL /root/$MODEL -RUN mkdir /root/bundles && ersilia_model_pack --repo_path $MODEL --bundles_repo_path /root/bundles && \ + +RUN apt-get update && apt-cache search libxtst && \ + apt-get install -y libfontconfig1 libxrender1 libxtst6 && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN apt-get update && \ + apt-get install -y git && \ + mkdir /root/bundles && ersilia_model_pack --repo_path $MODEL --bundles_repo_path /root/bundles && \ + apt-get remove --purge -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* && \ rm -rf /root/$MODEL && rm -rf /root/.cache && \ cp /root/bundles/$MODEL/*/information.json /root/information.json && \ cp /root/bundles/$MODEL/*/api_schema.json /root/api_schema.json && \ diff --git a/ersilia/hub/content/card.py b/ersilia/hub/content/card.py index 8ab93605..4ee1a1fd 100644 --- a/ersilia/hub/content/card.py +++ b/ersilia/hub/content/card.py @@ -68,7 +68,7 @@ class BaseInformation(ErsiliaBase): Configuration settings in JSON format. """ - def __init__(self, config_json): + def __init__(self, config_json=None): ErsiliaBase.__init__( self, config_json=config_json, credentials_json=None ) diff --git a/ersilia/serve/services.py b/ersilia/serve/services.py index 21f0332a..04376332 100644 --- a/ersilia/serve/services.py +++ b/ersilia/serve/services.py @@ -1237,6 +1237,10 @@ def _get_apis(self): self.logger.debug("Status code: {0}".format(response.status_code)) if response.status_code == 502: raise BadGatewayError(url) + elif response.status_code == 405: # We try the GET endpoint here + response = requests.get(url) + else: + response.raise_for_status() apis_list = json.loads(response.text)["apis_list"] self.logger.debug("Writing file {0}".format(file_name)) with open(file_name, "w") as f: