Skip to content
Open
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
17 changes: 12 additions & 5 deletions mlops/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
else:
self.check_dirty()

self.check_minio_credentials()
self.config_setup()
self.use_gpu = self.check_gpu()
self.env_setup()
self.check_minio_credentials()
self.use_gpu = self.check_gpu()
self.build_project_file()
self.init_experiment()

Expand All @@ -74,9 +74,10 @@
def check_minio_credentials(self):
self.auth = boto3.session.Session().get_credentials()
if self.auth is None:
logger.debug('Minio credentials NOT found')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition

raise Exception("minio credentials not found - either specify in ~/.aws/credentials or using environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)")

Check failure on line 78 in mlops/Experiment.py

View workflow job for this annotation

GitHub Actions / unit_tests (ubuntu-latest, 3.9)

E501 line too long (171 > 127 characters)
else:
logger.debug(f'Found minio credentials in {self.auth.method}')
raise Exception(
f'minio credentials not found - either specify in ~/.aws/credentials or using environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)')

def check_dirty(self) -> bool:
"""
Expand Down Expand Up @@ -124,6 +125,9 @@
os.environ['MLFLOW_TRACKING_URI'] = self.config['server']['MLFLOW_TRACKING_URI']
os.environ['MLFLOW_S3_ENDPOINT_URL'] = self.config['server']['MLFLOW_S3_ENDPOINT_URL']

os.environ['AWS_ACCESS_KEY_ID'] = self.config['minio']['AWS_ACCESS_KEY_ID']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, credentials are fetched from the .env file, not the config file

os.environ['AWS_SECRET_ACCESS_KEY'] = self.config['minio']['AWS_SECRET_ACCESS_KEY']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


def init_experiment(self):
"""
Initialises experiment for tracking with mlflow.
Expand Down Expand Up @@ -178,7 +182,7 @@

self.minio_cred = {'user': os.getenv('AWS_ACCESS_KEY_ID'),
'password': os.getenv('AWS_SECRET_ACCESS_KEY')}

# todo: replace this with either a machine level IAM role or ~/.aws/credentials profile
os.environ['MINIO_ROOT_USER'] = os.getenv('AWS_ACCESS_KEY_ID')
os.environ['MINIO_ROOT_PASSWORD'] = os.getenv('AWS_SECRET_ACCESS_KEY')
Expand Down Expand Up @@ -245,6 +249,7 @@
:param kwargs:
:return:
"""

rebuild_docker = kwargs.get('rebuild_docker', False)
shared_memory = kwargs.get('shared_memory', '8gb')

Expand Down Expand Up @@ -274,8 +279,10 @@
docker_args_default = docker_args_default

# check image exists and build if not

logger.info('Checking for existing image')
client = docker.from_env()

images = [str(img['RepoTags']) for img in client.api.images()]
if all([(self.experiment_name + ':latest') not in item for item in images]) or rebuild_docker:
logger.info(f'No existing image found, rebuild flag {rebuild_docker}')
Expand Down
Loading