|
1 | 1 | Installing IMASPy |
2 | 2 | ================= |
3 | 3 |
|
4 | | -IMASPy is a Python package with a compiled component, specifically the |
5 | | -:al_cython:`Cython layer of the IMAS Access Layer (AL) <browse>`. This component |
6 | | -is optional, but necessary to interact with the IMAS-AL, and thus with data stored |
7 | | -to disk by said AL. |
| 4 | +IMASPy is a pure Python package. For full functionality of the package you need |
| 5 | +an installation of `the IMAS Access Layer <https://imas.iter.org/>`_. See |
| 6 | +:ref:`IMASPy 5 minute introduction` for an overview of functionality which does |
| 7 | +(not) require the IMAS Access Layer available. |
8 | 8 |
|
9 | | -IMASPy also needs the :al_lib:`IMAS Python helper functions <browse>`. Currently, both |
10 | | -dependencies are pulled it using :std:doc:`GitPython <gitpython:index>`, until the |
11 | | -:issue:`separate Python HLI parts are available as packages <IMAS-584>`. |
12 | 9 |
|
13 | | -.. :std:doc:`Cython <cython:index>` of the |
| 10 | +Installing on the ITER cluster and EuroFusion gateway |
| 11 | +----------------------------------------------------- |
14 | 12 |
|
15 | | -
|
16 | | -Python is very flexible, and so is it's install procedure. This is a double-edged sword: |
17 | | -Because of it flexibility, many different install options are available and in use in the |
18 | | -community. For an introduction to the topic, read the |
19 | | -:pypa:`guide to installing Python packaging by the Python Packaging Authority (PyPA) <tutorials/installing-packages/>`. |
20 | | - |
21 | | -Installing on the ITER cluster |
22 | | ------------------------------- |
23 | | -To interact with the AL, we need the IMAS environment |
24 | | -activated. I'm assuming a bash shell for all these commands: |
25 | | - |
26 | | -.. code-block:: bash |
27 | | -
|
28 | | - module load IMAS-2020a/3.30.0-4.8.5-2020a |
29 | | -
|
30 | | -This should give us all we need, namely at time of testing: |
31 | | - |
32 | | -* ``python`` with a recent version: ``python --version #Python 3.8.2`` |
33 | | -* The Python package installer ``pip``: |
34 | | - ``pip --version #pip 20.0.2 from /work/imas/opt/EasyBuild/software/Python/3.8.2-GCCcore-9.3.0/lib/python3.8/site-packages/pip-20.0.2-py3.8.egg/pip (python 3.8)`` |
35 | | - |
36 | | -We are all developers, install imaspy in `pip editable <https://pip.pypa.io/en/stable/reference/pip_install/#options>`_ /`setuptools develop <https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode>`_ mode. **We are not using PEP517 build isolation to link to the systems numpy.**, **We are not using PyPA's recommended environment management, but instead install into the USER_SITE, this is ~/.local by default.** |
| 13 | +There is a `module` available on the ITER and Eurofusion Gateway clusters, so |
| 14 | +you can run |
37 | 15 |
|
38 | 16 | .. code-block:: bash |
39 | 17 |
|
40 | | - git clone git@git.iter.org/IMAS/imaspy.git |
41 | | - pip install --user -e imaspy |
42 | | -
|
| 18 | + module load IMASPy |
43 | 19 |
|
44 | | -We should now be able to run the tests |
| 20 | +Additionally, if you wish to use the MDSPlus backend, you should load |
45 | 21 |
|
46 | 22 | .. code-block:: bash |
47 | 23 |
|
48 | | - pip install --user -r requirements_test.txt |
49 | | - pytest imaspy/ --mini |
50 | | -
|
51 | | -Note that at the time of writing access layer version 4.8.5 has an issue which causes |
52 | | -several tests to fail. |
53 | | - |
54 | | -Develop install |
55 | | -^^^^^^^^^^^^^^^ |
| 24 | + module load MDSplus-Java/7.96.17-GCCcore-10.2.0-Java-11 |
56 | 25 |
|
57 | | -.. note:: Check if this is still needed |
58 | 26 |
|
59 | | -pip install --user -e .[backends_al,backends_xarray,test] |
| 27 | +Local installation |
| 28 | +------------------ |
60 | 29 |
|
61 | | -Check if you have access to the AL repository. This is currently needed to pull 'secret' dependencies. This will be checked by `pip` too but better to know it now. |
62 | | - |
63 | | -* Access to ``libimas.a``, located in ``$IMAS_PREFIX/lib``: |
64 | | - ``ls $IMAS_PREFIX/lib/libimas #/work/imas/core/IMAS/3.28.1-4.8.3/lib/libimas.a`` |
65 | | - in our ``LD_LIBRARY_PATH=$IMAS_PREFIX/lib:$LD_LIBRARY_PATH`` |
66 | | -* A ``UAL_VERSION``, which will be used to pull the low-level AL files from the ITER |
67 | | - repository. ``echo $UAL_VERSION #4.8.3`` |
| 30 | +We recommend using a :external:py:mod:`venv`. Then, clone the IMASPy repository |
| 31 | +and run `pip install`: |
68 | 32 |
|
69 | 33 | .. code-block:: bash |
70 | 34 |
|
71 | | - (git ls-remote ssh://git@git.iter.org/imas/access-layer.git > /dev/null) && echo 'Connection successful!' || echo 'Connection failed!' |
72 | | - # Connection successful! |
| 35 | + python3 -m venv ./venv |
| 36 | + . venv/bin/activate |
| 37 | + git clone ssh://git@git.iter.org/imas/imaspy.git |
| 38 | + cd imaspy |
| 39 | + pip install --upgrade pip |
| 40 | + pip install --upgrade wheel setuptools |
| 41 | + pip install . |
73 | 42 |
|
74 | 43 |
|
75 | | -Quick primer on Python packages |
76 | | -------------------------------- |
77 | | -A :pypa:`Python package <glossary/#term-import-package>`, commonly just called 'package', is a collection of :pypa:`Python modules <glossary/#term-module>`; reusable pieces of Python code. After installation, these packages are importable in scripts of other users, with the ``import package_name`` statement. On HPC systems, packages available to the user come from the following common locations: |
| 44 | +Development installation |
| 45 | +------------------------ |
78 | 46 |
|
79 | | -1. From the globally installed Python packages. These are installed by the system administrator (e.g. someone with `sudo` rights). For example on the ITER cluster: |
| 47 | +For development an installation in editable mode may be more convenient, and you |
| 48 | +will need some extra dependencies to run the test suite and build documentation. |
80 | 49 |
|
81 | 50 | .. code-block:: bash |
82 | 51 |
|
83 | | - module purge |
84 | | - module load Python/3.6.4-intel-2018a |
85 | | - python -c 'import site; print(site.getsitepackages())' |
86 | | - # ['/work/imas/opt/EasyBuild/software/Python/3.6.4-intel-2018a/lib/python3.6/site-packages'] |
| 52 | + pip install -e .[test, docs] |
87 | 53 |
|
88 | | -2. From imported modules. These are usually centrally managed and also handled by the system administrator. For example on the ITER cluster: |
| 54 | +Test your installation by trying |
89 | 55 |
|
90 | 56 | .. code-block:: bash |
91 | 57 |
|
92 | | - module purge |
93 | | - module load Python/3.6.4-intel-2018a PyAL |
94 | | - python -m site |
95 | | - # sys.path = [ |
96 | | - # <snip> |
97 | | - # '/work/imas/opt/EasyBuild/software/Python/3.6.4-intel-2018a/lib/python3.6/site-packages/numpy-1.14.0-py3.6-linux-x86_64.egg' |
98 | | - # <snip> |
99 | | - # ] |
100 | | -
|
101 | | -3. From the local user environment, usually in the users' HOME directory: |
| 58 | + cd ~ |
| 59 | + python -c "import imaspy; print(imaspy.__version__)" |
102 | 60 |
|
103 | | -.. code-block:: bash |
104 | 61 |
|
105 | | - python -c 'import site; print(site.USER_SITE)' |
106 | | - # /home/ITER/vandepk/.local/lib/python3.6/site-packages |
| 62 | +Installation without ITER access |
| 63 | +-------------------------------- |
107 | 64 |
|
108 | | -4. From the current working directory. E.g. if I have a file called ``fancy_code.py`` in my current folder, I can call ``from fancy_code import *`` from my other Python files. |
| 65 | +The installation script tries to access the `ITER IMAS Core Data Dictionary |
| 66 | +repository <https://git.iter.org/projects/IMAS/repos/data-dictionary/browse>`_ |
| 67 | +to fetch the latest versions. If you do not have git+ssh access there, you can |
| 68 | +try to find this repository elsewhere, and do a ``git fetch --tags``. |
109 | 69 |
|
110 | | -Installing a Python package just means putting the Python files somewhere the python binary can find it. It does this by walking down the `sys.path` until a package with the right name is found. See :std:doc:`python:library/importlib` |
| 70 | +Alternatively you could try to obtain an ``IDSDef.zip`` and place it in |
| 71 | +``~/.config/imaspy/``. |
0 commit comments