ML4GW / pinto

Job environment management and execution tool
0 stars 3 forks source link

Better error message if a command is not in environment #35

Open EthanMarx opened 1 year ago

EthanMarx commented 1 year ago

if pinto run is called with a command that is not available in the corresponding environment, it will throw a FileNotFoundError, which can be misleading.

My guess is that pinto is trying to access the command, doesn't find it, and then assumes the user is trying to run a pipeline, looks for a pyproject.toml, and likely also doesn't find that. Maybe loggingf"command {command} not found in environment {env}"after the check for the command would be more clear.

alecgunny commented 1 year ago

So it's not actually a pinto thing, pinto leaves it to the underlying subprocess call to try to run the executable you give it and then raise whatever error it wants when/if it fails. For poetry projects, this is done with subprocess.Popen, and I agree that their choice of FileNotFoundError for a missing executable is less than helpful.

For conda projects, I think they call subprocess.run but I'd have to double check. The error isn't super clean, but you at least get a command not found at the end. Conda is tricky because they wrap each conda run call in a complicated shell script which manages the setup and cleanup of the conda environment.

So agree standardizing this across the two projects would be helpful, would just be a matter of how best to search each environment for the existence of the executable in a standardized way.