magmap.io.load_env module

Cross-platform environment activation and MagellanMapper launcher script.

Launches MagellanMapper within a Conda or Venv environment. Environment activation is in this order: * If a Conda or Venv environment is already activate, launch in current

environment

  • Attempt to activate a Conda environment

  • Attempt to activate a Venv environment

This script is designed to run MagellanMapper without assuming that a Python environment has been activated. It does assume that an environment has been generated and can be identified.

Executing this script as a text file (ie not through Python directly) assumes that the python command is accessible without a Python environment. Use bin/runaltpy.sh instead if only python3 is available (eg on Linux) or python is only available through Conda.

Conda activation assumes that the conda command is accessible, typically from a previous initialization through conda init (preferred) or by adding the conda binary directory to the PATH. Note that conda may not be available in environments that do not load the full shell configuration such as Python launched via Finder in the macOS platform.

magmap.io.load_env.ARGS_MAGMAP = ['python -u -c "from magmap.io import cli; cli.main(); from magmap.gui import visualizer; visualizer.main()" -T -b html -d _build/doctrees -D language=en . /home/docs/checkouts/readthedocs.org/user_builds/magellanmapper/checkouts/latest/_readthedocs//html']

Shell commands to launch the MagellanMapper.

Type:

List[str]

magmap.io.load_env.ENV_NAME = 'mag'

Name of Conda or Venv environment

Type:

str

magmap.io.load_env.VENV_DIR = '../venvs'

Directory with Venvs directories.

Type:

str

magmap.io.load_env.is_conda_activated()[source]

Check whether the MagellanMapper Conda environment is active.

The environment name does not have to exactly match ENV_NAME but at least start with this name to provide some flexibility for different versions of this environment, such as mag2.

Returns:

True if a Conda environment starting with the name ENV_NAME is currently activated.

Return type:

bool

magmap.io.load_env.is_venv_activated()[source]

Check whether a Venv or virtualenv environment is active.

Returns:

True if the environment is activated.

magmap.io.load_env.launch_magmap()[source]

Launch MagellanMapper.

First launch the CLI to process user arguments, which will shut down the process afterward if a CLI task has been selected. If the process remains alive, the GUI will be launched.

magmap.io.load_env.launch_subprocess(args, working_dir=None, sys_shell=False)[source]

Launch a subprocess with multiple commands strung together by logical ands.

Parameters:
  • args (List) – List of shell commands.

  • working_dir (str) – Working directory path; defaults to None.

  • sys_shell (bool) – True to launch the subprocess in the system shell; otherwise, args will be run in an interactive Bash shell. Defaults to False.

Returns:

0 if the return code was 0; otherwise, raises a subprocess.CalledProcessError.

Return type:

int

magmap.io.load_env.log_uncaught_exception(exc_type, exc, trace)[source]

Handle uncaught exceptions globally with logging.

Parameters:
  • exc_type – Exception class.

  • exc – Exception instance.

  • trace – Traceback object.

Returns:

magmap.io.load_env.main()[source]

Launch MagellanMapper with environment activation.

If necessary, attempt to activate a virtual environment created by MagellanMapper.