diff --git a/docs/index.md b/docs/index.md index 2ae71f8..d911edb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -43,17 +43,6 @@ Prepare a `spotty.yaml` file and put it to the root directory of your project: - Read [this](https://medium.com/@apls/how-to-train-deep-learning-models-on-aws-spot-instances-using-spotty-8d9e0543d365){:target="_blank"} article for a real-world example. -### __Create an AMI__ - -Run the following command from the root directory of your project: - -```bash -$ spotty aws create-ami -``` - -In several minutes you will have an AMI with NVIDIA Docker that Spotty will use -for all your projects within the AWS region. - ### __Start an instance__ Use the following command to launch an instance with the Docker container: diff --git a/spotty/providers/aws/deployment/instance_deployment.py b/spotty/providers/aws/deployment/instance_deployment.py index b816707..1d39f14 100644 --- a/spotty/providers/aws/deployment/instance_deployment.py +++ b/spotty/providers/aws/deployment/instance_deployment.py @@ -195,16 +195,23 @@ def _get_template_parameters(self, instance_profile_arn: str, instance_name: str return parameters def _get_ami(self) -> Image: + """Returns an AMI that should be used for deployment. + + Raises: + ValueError: If an AMI not found. + """ if self.instance_config.ami_id: + # get an AMI by ID if the "amiId" parameter is specified image = Image.get_by_id(self._ec2, self.instance_config.ami_id) if not image: - ValueError('AMI with ID=%s not found.' % self.instance_config.ami_id) + raise ValueError('AMI with ID=%s not found.' % self.instance_config.ami_id) else: + # try to get an AMI by its name (if the "amiName" parameter is not specified, the default value is used) image = Image.get_by_name(self._ec2, self.instance_config.ami_name) if not image: if self.instance_config.has_ami_name: - # AMI with the name specified in the configuration file was not found - ValueError('AMI with the name "%s" was not found.' % self.instance_config.ami_name) + # if an AMI name was explicitly specified in the config, but the AMI was not found, raise an error + raise ValueError('AMI with the name "%s" was not found.' % self.instance_config.ami_name) else: # get the latest "Deep Learning Base AMI" res = self._ec2.describe_images(