Skip to content

Commit 9ac5f30

Browse files
authored
Merge pull request #252 from MAAP-Project/add-ref-to-example-yaml-files
2 parents 6a1b343 + 2fc2b7e commit 9ac5f30

File tree

2 files changed

+34
-236
lines changed

2 files changed

+34
-236
lines changed

docs/source/system_reference_guide/custom-environments.ipynb

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"\n",
3939
"### Package manager\n",
4040
"\n",
41-
"We use `mamba` (a fast `conda` drop-in replacement) as a package manager to install, update or remove packages (libraries). `mamba` works with 'environments' that are directories in your local file system containing a set of packages. When you work 'in a given environment', it means you that your programs will look for dependencies in that environment's `mamba` directory. All workspaces launch with a environment called `base`, which is a `mamba` environment that has all the pre-installed libraries. If you open a terminal launcher after creating a `Basic Stable` workspace : \n",
41+
"We use `mamba` (a fast `conda` drop-in replacement) as a package manager to install, update or remove packages (libraries). `mamba` works with 'environments' that are directories in your local file system containing a set of packages. When you work 'in a given environment', it means that your programs will look for dependencies in that environment's `mamba` directory. All workspaces launch with an environment called `base`, which is a `mamba` environment that has all the pre-installed libraries. If you open a terminal launcher after creating a `Basic Stable` workspace : \n",
4242
"\n",
4343
"\n",
4444
"![Base conda environment location](../_static/base_conda_environment_location.png)\n",
@@ -49,14 +49,19 @@
4949
"\n",
5050
"**Note : any modification to the `base` environment does not survive a workspace restart. In other words, modifications to `/opt/conda` disappear after a workspace restart**. \n",
5151
"\n",
52-
"Extending an existing `mamba` environment means adding packages on top of what it contains, which works provided there are no dependency conflicts. You can use a configuration file specifying all the new libraries to add. It is recommended for reproducibility and shareability. See the below sections for configuration file usage. \n",
53-
"\n",
54-
"Alternatively, you can install libraries using the `mamba install` command to install additional packages in your current environment (run `mamba --help` to learn more about how to use `mamba` commands). For example :\n",
52+
"Extending an existing `mamba` environment means adding packages on top of what it contains, which works provided there are no dependency conflicts. You can install libraries using the `mamba install` command to install additional packages in your current environment (run `mamba --help` to learn more about how to use `mamba` commands). For example :\n",
5553
"\n",
5654
"```\n",
5755
"mamba install xarray\n",
5856
"```\n",
59-
"\n"
57+
"\n",
58+
"However, it is recommended to use configuration files for reproducibility and shareability. With this approach, assuming your configuration file is named `config.yml`, the command to use is : \n",
59+
"\n",
60+
"```\n",
61+
"mamba env update -f config.yml\n",
62+
"```\n",
63+
"\n",
64+
"For more details on configuration files, see the [Custom environments section](#Custom-environments) and for an example of this command, refer to the [subsection about updating an environment with a configuration file](#Updating-an-existing-environment-with-a-configuration-file).\n"
6065
]
6166
},
6267
{
@@ -66,19 +71,21 @@
6671
"source": [
6772
"## Custom environments\n",
6873
"\n",
69-
"Note that for the rest of this README, you can find the example configuration files in the `examples-environment-configuration-files` page, in the same section as this page.\n",
74+
"*For the rest of this README, in each section we provide a link to download an example YAML configuration file.*\n",
7075
"\n",
7176
"You can use the `mamba` CLI to create a new, custom environment. The parameters (the list of libraries, the location where to search for them, etc...) can be passed either from a configuration YAML file or directly on the console. We recommend using the first option (a YAML file is easier to share and modify). \n",
7277
"\n",
7378
"### Basic custom environment\n",
7479
"\n",
75-
"See the `env-example` in the examples notebook. This configuration installs specific versions `python`, `pandas` and `geopandas` from `conda-forge`. If versions aren't specified, the latest is installed. We recommend to always specify the version for reproducibility. The basic command to create this environment would be :\n",
80+
"*Example config file for this section [here](./example_conda_configuration_files/env-example.yml).*\n",
81+
"\n",
82+
"This configuration installs specific versions `python`, `pandas` and `geopandas` from `conda-forge`. If versions aren't specified, the latest is installed. We recommend to always specify the version for reproducibility. The basic command to create this environment would be :\n",
7683
"\n",
7784
"```\n",
7885
"mamba env create -f env-example.yml\n",
7986
"```\n",
8087
"\n",
81-
"However, this stores this environment files in `/opt/conda`, which a directory that is reset when the workspace restarts, and so custom environments are lost. Therefore, you want to specify a storage location in your user directory with the `--prefix` parameter\n",
88+
"However, this stores this environment files in `/opt/conda`, which is a directory that is recreated when the workspace restarts, and so custom environments are lost. Therefore, you want to specify a storage location in your user directory with the `--prefix` parameter\n",
8289
"\n",
8390
"```\n",
8491
"mamba env create -f env-example.yml --prefix /projects/env\n",
@@ -92,19 +99,31 @@
9299
"\n",
93100
"### Updating an existing environment with a configuration file\n",
94101
"\n",
95-
"You can update an existing environment with a configuration file as well. For example, let's assume you have a `mamba` environment with a set of packages already installed in it (for example the `base` environment), but it doesn't have `xarray` and `geopandas`. See the `env-extend` example in configuration examples notebook. Running `mamba env update -f env-extend.yml` will update `base` by adding `xarray` and `geopandas`, provided it does not cause conflicts with the existing libraries. \n",
102+
"*Example config file for this section [here](./example_conda_configuration_files/env-extend.yml).*\n",
103+
"\n",
104+
"You can *update* an existing environment with a configuration file as well. For example, let's assume you have a `mamba` environment with a set of packages already installed in it (for example the `base` environment), but it doesn't have `xarray` and `geopandas`. Using the linked example config : \n",
105+
"\n",
106+
"```\n",
107+
"mamba env update -f env-extend.yml\n",
108+
"```\n",
109+
"\n",
110+
"This command will update `base` by adding `xarray` and `geopandas`, provided it does not cause conflicts with the existing libraries. \n",
96111
"\n",
97112
"\n",
98113
"### Using `pip` for python packages\n",
99114
"\n",
100-
"Some python packages might not be availabe in the channel you are using, or in any `mamba` channel. If that package however is in `PyPI` (the official python package repository), one can use `pip` within a `mamba` environment to download packages. The recommended way is to specify this in the configuration file. An example of this configuration in the examples notebook is `env-with-pip`. In that example, we add `stackstac` as a dependency to install from `PyPI` because it is not available in the `conda-forge` channel. \n",
115+
"*Example config file for this section [here](./example_conda_configuration_files/env-with-pip.yml).*\n",
116+
"\n",
117+
"Some python packages might not be availabe in the channel you are using, or in any `mamba` channel. If that package however is in `PyPI` (the official python package repository), one can use `pip` within a `mamba` environment to download packages. The recommended way is to specify this in the configuration file. In the linked example, we add `stackstac` as a dependency to install from `PyPI` because it is not available in the `conda-forge` channel. \n",
101118
"\n",
102119
"### Using custom environments in jupyter notebooks\n",
103120
"\n",
121+
"*Example config file for this section [here](./example_conda_configuration_files/env-with-ipykernel.yml).*\n",
122+
"\n",
104123
"The following instruction steps are for python kernels.\n",
105124
"\n",
106-
"- Make sure ipykernel is listed as a dependency in your configuration file. See the `env-with-ipykernel` example in the examples notebook.\n",
107-
"- Create your environment using that configuration file.\n",
125+
"- Make sure ipykernel is listed as a dependency in your configuration file.\n",
126+
"- Create your environment using the linked configuration file.\n",
108127
"- Install the environment as a kernel by running the following command (parameter values follow the example mentioned):\n",
109128
" ```\n",
110129
" python -m ipykernel install --user --name env-with-ipykernel --display-name \"Python env-with-ipykernel\".\n",
@@ -115,7 +134,9 @@
115134
"\n",
116135
"### Suggested packages for custom environment\n",
117136
"\n",
118-
"MAAP users typically use the python `maap-py`. It's pre-installed in all workspaces, in the `base` mamba environment, but any custom environment should specify it, otherwise it is not going to be accessible from that environment. However, `maap-py` is not packaged in a public package repository, like `PyPI` or `conda-forge`. It is possible to install it directly from its github repository with `pip` though. See the `env-with-maap-py` example in the examples notebook. You can note that inside of it `maap-py` is 'versioned' using a commit hash (at the end of the github URL). "
137+
"*Example config file for this section [here](./example_conda_configuration_files/env-with-maap-py.yml)*\n",
138+
"\n",
139+
"MAAP users typically use the python `maap-py`. It's pre-installed in all workspaces, in the `base` mamba environment, but any custom environment should specify it, otherwise it is not going to be accessible from that environment. However, `maap-py` is not packaged in a public package repository, like `PyPI` or `conda-forge`. It is possible to install it directly from its github repository with `pip` though. See the configuration example linked. You can note that in the example, `maap-py` is 'versioned' using a commit hash (at the end of the github URL). "
119140
]
120141
}
121142
],

docs/source/system_reference_guide/examples-environment-configuration-files.ipynb

Lines changed: 0 additions & 223 deletions
This file was deleted.

0 commit comments

Comments
 (0)