Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAI-1255 MLFlow Model Imports #1341

Merged
merged 5 commits into from
Jul 1, 2024
Merged

Conversation

bw27492
Copy link
Member

@bw27492 bw27492 commented Jun 20, 2024

No description provided.

:param visibility: Visibility of model on Bailo, using ModelVisibility enum (e.g Public or Private), defaults to None
:return: A model object
"""
if mlflow:
Copy link
Member

Choose a reason for hiding this comment

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

Should be ml_flow given the boolean variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

else:
sel_model = res[0]

if not sel_model:
Copy link
Member

Choose a reason for hiding this comment

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

Should use if sel_model is None

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Comment on lines 145 to 152
if version:
for model in res:
if model.version == version:
sel_model = model
break
sel_model = None
else:
sel_model = res[0]
Copy link
Member

Choose a reason for hiding this comment

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

sel_model is possibly unset which will cause a NameError when trying to access it. Instead you should move sel_model = None above if version and remove the break.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

)

mlflow_run = mlflow_client.get_run(run_id)
artifact_uri = mlflow_run.info.artifact_uri
Copy link
Member

Choose a reason for hiding this comment

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

Possibly undefined. Could there be some error handling to catch this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

)

name = sel_model.name
description = sel_model.description + " Imported from MLFlow."
Copy link
Member

Choose a reason for hiding this comment

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

description could be None?

Copy link
Member Author

Choose a reason for hiding this comment

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

MLFlow sets description as '' by default so this shouldn't be an issue

Comment on lines 129 to 130
def mlflow_uri():
return "http://127.0.0.1:5001"
Copy link
Member

Choose a reason for hiding this comment

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

Using a fixture is only benificial if you're generating something. Here you can just use it as a constant as there's no additional computation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Used pytest_configure to set a global variable

:param visibility: Visibility of model on Bailo, using ModelVisibility enum (e.g Public or Private), defaults to None
:return: A model object
"""
if ml_flow:
Copy link
Member

Choose a reason for hiding this comment

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

Invert these checks so that the error message is location by the if statement. E.g. instead of:

if x:
  if y:
    if z:
      // do a
    else:
      throw 'z'
  else:
    throw 'y'
else:
  throw 'x'

Instead:

if not x:
  throw 'x'

if not y:
  throw 'y'

if not z:
  throw 'z'

// do a

At the moment I have to scroll through ~30 lines of code to see where the source is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@bw27492 bw27492 merged commit cef9d3d into main Jul 1, 2024
14 checks passed
@bw27492 bw27492 deleted the BAI-1255-mlflow-models-and-datasets branch July 1, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants