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 to make sure env is set up properly #154

Open
sgoodm opened this issue Jan 26, 2023 · 5 comments
Open

Check to make sure env is set up properly #154

sgoodm opened this issue Jan 26, 2023 · 5 comments
Assignees

Comments

@sgoodm
Copy link
Member

sgoodm commented Jan 26, 2023

Primarily an issue with deployments, but could also cause issues across run modes.

Currently if the env is not set up properly (e.g., for the agent - loading conda env, setting tmpdir) there is a largely silent failure and Prefect will just hang. The only clue is that the logs from the failed dask-workers will have something along the lines of "could not find temp directory".

Ideally, we should recognize the env is not set up and throw a warning, and terminate the deployment before it gets started

@jacobwhall
Copy link
Member

Here is some code to test if the current conda environment is correct, tested on a vortex compute node:

import os

logger = self.get_logger()

correct_env = "geodata38"

try:
    conda_env = os.environ["CONDA_DEFAULT_ENV"]
except KeyError:
    logger.warning("No conda environment detected! Have you loaded the anaconda module and activated an environment?")
else:
    if conda_env != correct_env:
        logger.warning(f"Your conda environment is {conda_env} instead of {correct_env}!")

@jacobwhall
Copy link
Member

And here is some code to test if the current $TMPDIR environment variable points to within /local/, the default on HPC vortex nodes. I've tested this too

import os
from pathlib import Path

logger = self.get_logger()

try:
    tmp_dir = Path(os.environ["TMPDIR"]).resolve(strict=True)
except KeyError:
    logger.warning("No $TMPDIR environment variable found!")
except FileNotFoundError:
    logger.warning("$TMPDIR path not found!")
else:
    slash_local = Path("/local").resolve()
    for p in tmp_dir.parents:
        if p.resolve() == slash_local:
            logger.warning("$TMPDIR in /local, deployments won't be accessible to compute nodes.")

@jacobwhall
Copy link
Member

@sgoodm are there other environment checks beyond #155 you'd like to add?

@jacobwhall jacobwhall self-assigned this Jan 30, 2023
@sgoodm
Copy link
Member Author

sgoodm commented Jan 30, 2023

@jacobwhall This is looking good - we may want to put the conda env in the config so it is easily changeable

@jacobwhall
Copy link
Member

we may want to put the conda env in the config so it is easily changeable

I agree we should make this configurable per-dataset. I'm hopeful my work on the "universal flow" (#146) could make thise easier to standardize across dataset scripts. If not, I can go back through them and add a conda_env variable to each run config.

Until then, I suggest we keep this issue open and merge #155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants