Adding data directory environment variable instructions.

This commit is contained in:
Matt Graham 2016-09-19 08:26:06 +01:00
parent 8c98867cfa
commit e390feaafd

View File

@ -146,7 +146,7 @@ This will create a new `mlpractical` subdirectory with a local copy of the repos
``` ```
cd mlpractical cd mlpractical
ls -a ls -a # Windows equivalent: dir /a
``` ```
For the most part this will look much like any other directory, with there being the following three non-hidden sub-directories: For the most part this will look much like any other directory, with there being the following three non-hidden sub-directories:
@ -250,6 +250,34 @@ import mlp
Running the `import` statement any further times will have no effect even if the underlying module code has been changed. To reload an already imported module we instead need to use the [`reload`](https://docs.python.org/2.7/library/functions.html#reload) function. Running the `import` statement any further times will have no effect even if the underlying module code has been changed. To reload an already imported module we instead need to use the [`reload`](https://docs.python.org/2.7/library/functions.html#reload) function.
## Adding a data directory variable to the environment
We observed previously the presence of a `data` subdirectory in the local repository. This directory holds the data files that will be used in the course. To enable the data loaders in the `mlp` package to locate these data files we need to set a `MLP_DATA_DIR` environment variable pointing to this directory.
Assuming you used the recommended Miniconda install location and cloned the `mlpractical` repository to your home directory, this variable can be automatically defined when activating the environment by running the following commands (on non-Windows systems):
```
cd ~/miniconda2/envs/mlp
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
echo -e '#!/bin/sh\n' >> ./etc/conda/activate.d/env_vars.sh
echo "export MLP_DATA_DIR=$HOME/mlpractical/data" >> ./etc/conda/activate.d/env_vars.sh
echo -e ''#!/bin/sh\n' >> ./etc/conda/deactivate.d/env_vars.sh
echo 'unset MLP_DATA_DIR' >> ./etc/conda/deactivate.d/env_vars.sh
```
And on Windows systems (replacing the `[]` placeholders with the relevant paths):
```
cd [path-to-conda-root]\envs\mlp
mkdir .\etc\conda\activate.d
mkdir .\etc\conda\deactivate.d
@echo "set MLP_DATA_DIR=[path-to-local-repository]\data" >> .\etc\conda\activate.d\env_vars.bat
@echo "set MLP_DATA_DIR=" >> .\etc\conda\deactivate.d\env_vars.bat
```
After running these commands, deactivate then reactivate your environment to define the variable in the current session.
## Loading the first lab notebook ## Loading the first lab notebook
Your environment is now all set up so you can move on to the introductory exercises in the first lab notebook. Your environment is now all set up so you can move on to the introductory exercises in the first lab notebook.