Skip to content

Commit

Permalink
docker architectures troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelduranfrigola committed Jun 26, 2023
1 parent 5b8678d commit 43463ce
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ersilia/cli/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def close(self):
m = importlib.import_module("ersilia.cli.commands.close")
m.close_cmd()

def current(self):
m = importlib.import_module("ersilia.cli.commands.current")
m.current_cmd()

def delete(self):
m = importlib.import_module("ersilia.cli.commands.delete")
m.delete_cmd()
Expand Down
17 changes: 17 additions & 0 deletions ersilia/cli/commands/current.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from . import ersilia_cli
from .. import echo
from ...core.session import Session


def current_cmd():
@ersilia_cli.command(
short_help="Get identifier of current model",
help="Get identifier of currently served model",
)
def current():
session = Session(config_json=None)
model_id = session.current_model_id()
if model_id is not None:
echo("Current model identifier: {0}".format(model_id), fg="blue")
else:
echo("No model is current served...", fg="yellow")
1 change: 1 addition & 0 deletions ersilia/cli/create_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def create_ersilia_cli():
cmd.catalog()
cmd.clear()
cmd.close()
cmd.current()
cmd.delete()
cmd.example()
cmd.fetch()
Expand Down
30 changes: 23 additions & 7 deletions ersilia/hub/pull/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
import requests

from ... import ErsiliaBase
from ...utils.terminal import yes_no_input
from ...utils.terminal import yes_no_input, run_command
from ... import throw_ersilia_exception
from ...utils.exceptions_utils.pull_exceptions import DockerImageNotAvailableError
from ...utils.exceptions_utils.pull_exceptions import (
DockerImageNotAvailableError,
DockerImageArchitectureNotAvailableError,
)

from ...utils.docker import SimpleDocker
from ...default import DOCKERHUB_ORG, DOCKERHUB_LATEST_TAG
Expand Down Expand Up @@ -78,11 +81,24 @@ def pull(self):
self.logger.debug(
"Pulling image {0} from DockerHub...".format(self.image_name)
)
self.client.images.pull(
"{0}/{1}".format(DOCKERHUB_ORG, self.model_id),
tag=DOCKERHUB_LATEST_TAG,
decode=True,
)
try:
self.client.images.pull(
"{0}/{1}".format(DOCKERHUB_ORG, self.model_id),
tag=DOCKERHUB_LATEST_TAG,
decode=True,
)
self.logger.debug("Image pulled succesfully!")
except:
self.logger.warning(
"Conventional pull did not work, Ersilia is now forcing linux/amd64 architecture"
)
run_command(
"docker pull {0}/{1}:{2} --platform linux/amd64".format(
DOCKERHUB_ORG, self.model_id, DOCKERHUB_LATEST_TAG
)
)
# except:
# raise DockerImageArchitectureNotAvailableError(model=self.model_id)
else:
self.logger.info("Image {0} is not available".format(self.image_name))
raise DockerImageNotAvailableError(model=self.model_id)
1 change: 1 addition & 0 deletions ersilia/serve/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def serve(self):
self._stop_all_containers_of_image()
self.container_name = "{0}_{1}".format(self.model_id, str(uuid.uuid4())[:4])
self.volumes = {self.tmp_folder: {"bind": "/ersilia_tmp", "mode": "rw"}}
self.logger.debug("Trying to run container")
self.container = self.client.containers.run(
self.image_name,
name=self.container_name,
Expand Down
9 changes: 9 additions & 0 deletions ersilia/utils/exceptions_utils/pull_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ def __init__(self, model):
model
)
super().__init__(self.message, self.hints)


class DockerImageArchitectureNotAvailableError(ErsiliaError):
def __init__(self, model):
self.message = "It was not possible to pull model {0} from Ersilia's DockerHub repository.".format(
model
)
self.hints = "If you are using an Apple M1/M2 chip, it is possible that this model is not supported for your architecture, unfortunately.\nOne possible alternative is to use GitHub Codespaces to run Ersilia on the cloud, and fetch the model from there. If you absolutely want this model to run on a Mac, please reach out to us and we will try to help."
super().__init__(self.message, self.hints)

0 comments on commit 43463ce

Please sign in to comment.