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

check ordered project directories candidates for project folders #1

Open
wants to merge 2 commits into
base: feat/getml_mlflow
Choose a base branch
from
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
28 changes: 18 additions & 10 deletions mlflow/getml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,39 @@ def save_model(
metadata=None,
):
import getml
import sys

_validate_env_arguments(conda_env, pip_requirements, extra_pip_requirements)
path = os.path.abspath(path)

_validate_and_prepare_target_save_path(path)
code_dir_subpath = _validate_and_copy_code_paths(code_paths, path)

getml_working_dir_candidates = []
current_user_home_dir = pathlib.Path.home()

getml_project_name = settings.get("project_name", getml.project.name) if settings else getml.project.name # type: ignore

if settings and (wd := settings.get("working_dir")):
if not pathlib.Path(wd).exists():
raise Exception(f"{wd} Working directory does not exists")
getml_working_dir = pathlib.Path(wd)
elif (wd := current_user_home_dir / ".getML").exists():
getml_working_dir = wd
getml_working_dir_candidates.append(pathlib.Path(wd))
if (wd := current_user_home_dir / ".getML").exists():
getml_working_dir_candidates.append(pathlib.Path(wd))
if site_package_inst:= [f for f in pathlib.Path(sys.executable).parents[1].rglob('.getML')]:
getml_working_dir_candidates.append(pathlib.Path(site_package_inst[0]))

if getml_working_dir_candidates:
for candidate in getml_working_dir_candidates:
if (
getml_project_folder := candidate / "projects" / getml_project_name
).exists():
print(f'getml working directory chosen: {getml_project_folder}')
break
else:
raise Exception(f"No project folder in any of these getml project directories exist: {getml_working_dir_candidates}")
else:
raise Exception("No default getML project directory")

assert getml_project_name
if not (
getml_project_folder := getml_working_dir / "projects" / getml_project_name
).exists():
raise Exception(f"{getml_project_folder} does not exists")

if mlflow_model is None:
mlflow_model = Model()

Expand Down