|
38 | 38 | "\n", |
39 | 39 | "### Package manager\n", |
40 | 40 | "\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", |
42 | 42 | "\n", |
43 | 43 | "\n", |
44 | 44 | "\n", |
|
49 | 49 | "\n", |
50 | 50 | "**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", |
51 | 51 | "\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", |
55 | 53 | "\n", |
56 | 54 | "```\n", |
57 | 55 | "mamba install xarray\n", |
58 | 56 | "```\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" |
60 | 65 | ] |
61 | 66 | }, |
62 | 67 | { |
|
66 | 71 | "source": [ |
67 | 72 | "## Custom environments\n", |
68 | 73 | "\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", |
70 | 75 | "\n", |
71 | 76 | "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", |
72 | 77 | "\n", |
73 | 78 | "### Basic custom environment\n", |
74 | 79 | "\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", |
76 | 83 | "\n", |
77 | 84 | "```\n", |
78 | 85 | "mamba env create -f env-example.yml\n", |
79 | 86 | "```\n", |
80 | 87 | "\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", |
82 | 89 | "\n", |
83 | 90 | "```\n", |
84 | 91 | "mamba env create -f env-example.yml --prefix /projects/env\n", |
|
92 | 99 | "\n", |
93 | 100 | "### Updating an existing environment with a configuration file\n", |
94 | 101 | "\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", |
96 | 111 | "\n", |
97 | 112 | "\n", |
98 | 113 | "### Using `pip` for python packages\n", |
99 | 114 | "\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", |
101 | 118 | "\n", |
102 | 119 | "### Using custom environments in jupyter notebooks\n", |
103 | 120 | "\n", |
| 121 | + "*Example config file for this section [here](./example_conda_configuration_files/env-with-ipykernel.yml).*\n", |
| 122 | + "\n", |
104 | 123 | "The following instruction steps are for python kernels.\n", |
105 | 124 | "\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", |
108 | 127 | "- Install the environment as a kernel by running the following command (parameter values follow the example mentioned):\n", |
109 | 128 | " ```\n", |
110 | 129 | " python -m ipykernel install --user --name env-with-ipykernel --display-name \"Python env-with-ipykernel\".\n", |
|
115 | 134 | "\n", |
116 | 135 | "### Suggested packages for custom environment\n", |
117 | 136 | "\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). " |
119 | 140 | ] |
120 | 141 | } |
121 | 142 | ], |
|
0 commit comments