Skip to content

Commit 991bdcb

Browse files
committed
Update python env modification docs
1 parent 97e93e0 commit 991bdcb

2 files changed

Lines changed: 40 additions & 97 deletions

File tree

compute/python.rst

Lines changed: 31 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ Python environments
33

44
Plenty of MagAO-X software is written in Python, so we need a consistent environment. We use the ``mamba`` distribution of the ``conda`` package manager (c.f. Anaconda) to manage it. (A mamba is a fast snake, and the ``mamba install`` command is orders of magnitude faster at solving environment installation requirements than plain old ``conda``.)
55

6-
Environment specifications are tracked in the same git repository as MagAO-X software, under the ``setup/`` folder.
6+
Environment specifications are tracked in https://github.com/magao-x/magao-x-setup/tree/main/conda_envs.
77

8-
``conda_env_base.yml`` stores just the top-level
9-
dependencies (i.e. not everything they depend on) without versions. This
10-
makes it easier to track what we *really* depend on in case we need to
11-
help conda along with failing dependency resolution.
8+
``xpy3_13.yml`` stores just the top-level dependencies (i.e. not everything they depend on) without versions.
9+
10+
.. warning::
11+
12+
Why not pin versions? It turns out that subtle forms of drift (yanked releases,
13+
x86 vs. ARM differences, etc.) mean that pinning specific versions does not work
14+
as well as you'd hope.
1215

13-
The files named variations on ``conda_env_pinned_*.yml`` reflect the actual set of
14-
packages installed in the environment. This lets us recreate/update
15-
(nearly) identical environments on AOC/RTC/ICC. The suffix allows us to track different
16-
pinned packages for different instruction set architectures.
1716

1817
Adding a package
1918
----------------
@@ -54,37 +53,26 @@ new package. Example:
5453
If it was installed via pip, the package will be in a sub-list under the
5554
``pip:`` heading.
5655

57-
Updating the environment template
58-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56+
Updating the instrument base environment
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5958

60-
To add it to the template, first pull any changes:
59+
To add it to the template, you need a copy of the setup files::
6160

62-
::
61+
cd
62+
git clone https://github.com/magao-x/magao-x-setup/
63+
cd magao-x-setup
64+
65+
If you have an existing clone, make sure to update it::
6366

64-
cd /opt/MagAOX/source/MagAOX
67+
cd ~/magao-x-setup
6568
git pull
6669
# resolve any conflicts
6770

68-
Then open ``/opt/MagAOX/source/MagAOX/setup/conda_env_base.yml``. You'll
69-
see something like what ``conda env export`` output, but without the version
71+
Then open ``conda_envs/xpy3_13.yml``. You'll
72+
see something like what ``conda env export`` outputs, but without the version
7073
numbers. Add your package name (but not version, unless you know what
71-
you're doing) to the list, being careful to put it under the ``pip:``
72-
heading if that's how it was installed.
73-
74-
Updating the list of pinned packages
75-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76-
77-
Now, you need to update the list of pinned packages and versions
78-
in ``/opt/MagAOX/source/MagAOX/setup/conda_env_pinned_$ARCH.yml`` (where ``$ARCH`` is your processor architecture) by
79-
exporting the current packages and versions from the system where you just installed a new package.
80-
81-
::
82-
83-
$ conda env export > /opt/MagAOX/source/MagAOX/setup/conda_env_pinned_$(uname -i).yml
84-
85-
This updates the versioned file in the MagAO-X source, and you can use ``git diff`` to see what has changed.
86-
87-
If you install on ARM this won't update the pinned packages on Intel/AMD, and vice versa. To keep a pinned environment for the other processor architecture, you will need to install the package there and repeat the export. (Reproducing the same environment exactly is impossible on a different processor architecture for any nontrivial set of packages.)
74+
you're doing) to the list. If it was installed using ``pip``, be sure to put it
75+
under the ``pip:`` heading.
8876

8977
Storing in version control
9078
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -94,8 +82,7 @@ and push them to the central copy.
9482

9583
::
9684

97-
$ cd /opt/MagAOX/source/MagAOX/setup
98-
$ git add conda_env_pinned_*.yml conda_env_base.yml
85+
git add conda_envs
9986
$ git commit -m "Added Python package foopkg to conda envs"
10087
$ git push
10188

@@ -107,9 +94,9 @@ and RTC and run the following steps:
10794

10895
::
10996

110-
$ cd /opt/MagAOX/source/MagAOX/setup
111-
$ git pull
112-
$ conda env update -f /opt/MagAOX/source/MagAOX/setup/conda_env_pinned_$(uname -i).yml
97+
git clone https://github.com/magao-x/magao-x-setup/
98+
cd magao-x-setup
99+
conda env update -f conda_envs/xpy3_13.yml
113100

114101
(Or, if you made the change another one of the machines, just run the above
115102
steps on the two **other** ones.)
@@ -118,9 +105,7 @@ Updating ``conda``
118105
------------------
119106

120107
If there are updates to ``conda`` itself, it'll probably tell you. You
121-
can run ``conda update -n base -c defaults conda`` to update it, but be
122-
sure to follow the steps beginning at `Updating the pinned
123-
packages <#Updating-the-pinned-packages>`__ to record the upgrade.
108+
can run ``conda update -n base -c defaults conda`` to update it.
124109

125110
Performing a fresh conda install/upgrade
126111
----------------------------------------
@@ -130,71 +115,22 @@ a new version of the Python interpreter itself, or both.
130115

131116
1. Move ``/opt/conda`` out of the way
132117
(i.e. ``mv /opt/conda /opt/conda.bak``)
133-
2. Edit ``/opt/MagAOX/source/MagAOX/setup/install_python.sh`` and change
118+
2. Edit ``~/magao-x-setup/steps/install_python.sh`` (adjust for path to your magao-x-setup clone) and change
134119
``MINICONDA_VERSION="X-pyXX_X.Y.Z"`` appropriately, and commit/push
135120
to version control.
136-
3. Run ``bash /opt/MagAOX/source/MagAOX/setup/install_python.sh`` to
121+
3. Run ``bash ~/magao-x-setup/steps/install_python.sh`` to
137122
download and install the new ``conda`` to ``/opt/conda`` with
138123
appropriate permissions
139124

140125
At this point you should **log out** and back in to reset any environment
141126
variables that were set by the old ``conda``.
142127

143-
If the Python version hasn't increased
144-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145128

146-
In most cases, the version of Python shipped with Miniconda hasn't
147-
changed.
129+
**Finally,** Run ``bash ~/magao-x-setup/steps/install_python_libs.sh``
130+
to install all our non-pip, non-conda dependencies.
148131

149-
4. Run ``bash /opt/MagAOX/source/MagAOX/setup/configure_python.sh``
150-
151-
If the Python version has changed
152-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153-
154-
The default ``configure_python.sh`` would try to restore the pinned
155-
versions from ``conda_env_pinned_$ARCH.yml``, but would fail because of the
156-
Python version mismatch. Instead, you need to create the environment
157-
from ``conda_env_base.yml`` and update ``conda_env_pinned_$ARCH.yml`` yourself
158-
159-
4. ``conda env update -f /opt/MagAOX/source/MagAOX/setup/conda_env_base.yml``
160-
5. ``conda env export > /opt/MagAOX/source/MagAOX/setup/conda_env_pinned_$(uname -i).yml``
161-
6. ::
162-
163-
$ cd /opt/MagAOX/source/MagAOX/setup
164-
$ git add conda_env_pinned_*.yml
165-
$ git commit -m "Updated pinned packages for conda upgrade"
166-
$ git push
167-
168-
169-
You will also need to rerun some of the files in
170-
``/opt/MagAOX/source/MagAOX/setup/steps`` that install Python packages
171-
into the environment. A (possibly incomplete) list:
172-
173-
::
174-
175-
cd /opt/MagAOX/source/MagAOX/setup/steps && \
176-
bash install_purepyindi.sh && \
177-
sudo /opt/conda/bin/pip install /opt/MagAOX/source/milk/src/ImageStreamIO/ && \
178-
bash install_magpyx.sh && \
179-
bash install_sup.sh
180132

181133
Replicate across all the machines
182134
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183135

184-
SSH to the other machines and:
185-
186-
1. Move ``/opt/conda`` out of the way
187-
(i.e. ``sudo mv /opt/conda /opt/conda.bak``)
188-
2. Update the MagAO-X source:
189-
``cd /opt/MagAOX/source/MagAOX && git pull``
190-
3. Install Python via miniconda:
191-
``bash /opt/MagAOX/source/MagAOX/setup/install_python.sh``
192-
4. Configure Python via conda environment files:
193-
``bash /opt/MagAOX/source/MagAOX/setup/configure_python.sh``
194-
5. Ensure all our custom packages get installed::
195-
196-
cd /opt/MagAOX/source/MagAOX/setup/steps && \
197-
bash install_purepyindi.sh && \
198-
sudo /opt/conda/bin/pip install /opt/MagAOX/source/milk/src/ImageStreamIO/ && \
199-
bash install_magpyx.sh && \
200-
bash install_sup.sh
136+
Repeat these steps on the other MagAO-X computers (or suffer the consequences).

compute/user_auth.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ accounts.xwcl.science
1717

1818
Powered by LLDAP ("lightweight LDAP", where the L stands for "lightweight" already).
1919

20-
Users can only reset their passwords.
21-
2220
The admin interface lets you add / remove users, add / remove groups, update passwords, and enroll new SSH keys for users (if you are a member of the ``ldap_admin`` LDAP group).
2321

22+
Password reset
23+
~~~~~~~~~~~~~~
24+
25+
Users can reset their own passwords using https://accounts.xwcl.science/. However, if they have previously logged in to an instrument computer, you may need to clear the credentials cache so the new password takes effect. On Rocky/Fedora hosts that looks like this::
26+
27+
$ sudo sssctl cache-expire -u USERNAME
28+
29+
replacing ``USERNAME`` with the user whose login info you need to refresh.
30+
2431
Adding a new user account
2532
~~~~~~~~~~~~~~~~~~~~~~~~~
2633

0 commit comments

Comments
 (0)