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

get_lib on Windows does not work in Python interactive #66

Open
nojaf opened this issue Oct 15, 2024 · 1 comment
Open

get_lib on Windows does not work in Python interactive #66

nojaf opened this issue Oct 15, 2024 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@nojaf
Copy link
Collaborator

nojaf commented Oct 15, 2024

Steps to reproduce:

  • Open an interactive Python session on Windows
import mlflow_go.lib
mlflow_go.lib.get_lib()

This will not work on Windows, workaround would be to run python -m mlflow_go.lib . . and set the MLFLOW_GO_LIBRARY_PATH environment variable to ".".

@nojaf nojaf added the help wanted Extra attention is needed label Oct 15, 2024
@nojaf
Copy link
Collaborator Author

nojaf commented Oct 15, 2024

The key problem here is that the tmpdir in

def _get_lib():
    # check if the library exists and load it
    path = pathlib.Path(
        os.environ.get("MLFLOW_GO_LIBRARY_PATH", pathlib.Path(__file__).parent.as_posix())
    ).joinpath(_get_lib_name()).absolute()
    if path.is_file():
        return _load_lib(path)

    logging.getLogger(__name__).warn("Go library not found, building it now")

    # build the library in a temporary directory and load it
    with tempfile.TemporaryDirectory() as tmpdir:
        return _load_lib(
            build_lib(
                pathlib.Path(__file__).parent.parent,
                pathlib.Path(tmpdir),
            )
        )

is being removed after it was invoked. In Windows you cannot delete a file you are executing, this is allowed on unix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant