Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a python-only installation #1861

Merged
merged 27 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1291245
add first attempt to a python-only installation
scarlehoff Nov 24, 2023
da4b199
hide fiatlux import
scarlehoff Nov 24, 2023
aa4a4e4
delay the deprecation
scarlehoff Nov 24, 2023
800e5b6
try modifying cmake with my eyes closed
scarlehoff Nov 24, 2023
43469ef
add poetry to host
scarlehoff Nov 24, 2023
8dcfd7b
remove complicated and costly versioning mechanisms :D
scarlehoff Nov 24, 2023
b3b97cf
dont use cmake to install python
scarlehoff Nov 24, 2023
d75dfb0
dont ignore _version while installing
scarlehoff Nov 24, 2023
28f27ea
set the version of poetry dynamic etc
scarlehoff Nov 24, 2023
1aba1a0
remove the setup.py for vp and n3fit
scarlehoff Nov 24, 2023
b1f3340
put back the python install within cmake
scarlehoff Nov 27, 2023
ac32ae6
remove version tuple
scarlehoff Nov 27, 2023
87c6c5e
specify the commit of reportengine
scarlehoff Nov 28, 2023
9fd65e4
Update validphys2/src/validphys/nnprofile.yaml
scarlehoff Nov 29, 2023
4deea2c
update references in the docs to nnpdfcpp and share
scarlehoff Nov 29, 2023
8e6ee05
add a mention to the fact that the share folder has been moved
scarlehoff Nov 30, 2023
e966f64
Update pyproject.toml
scarlehoff Dec 4, 2023
f492f6f
Update pyproject.toml
scarlehoff Dec 4, 2023
fcc11a9
Update CMakeLists.txt
scarlehoff Dec 4, 2023
7c1812b
error out if path not found
scarlehoff Dec 11, 2023
a9896fe
change the nnprofile defaults and definitions
scarlehoff Dec 14, 2023
b0387a8
add example nnprofile and expanduser paths
scarlehoff Dec 15, 2023
4b36079
update documentation on nnprofile
scarlehoff Dec 15, 2023
798bf88
add checks for all special nnprofile cases _and_ vp-get
scarlehoff Dec 16, 2023
3bc46a4
promote nnpdf_dir to module-level constant
scarlehoff Dec 17, 2023
2fdfc74
Apply suggestions from code review
scarlehoff Dec 18, 2023
a0f850e
consider the case of an empty profile
scarlehoff Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# extra files created to hold the versioning information
validphys2/src/validphys/_version.py

# extra files created by cmake
libnnpdf/nnprofile.yaml
libnnpdf/REAMDE.md
libnnpdf/scripts/nnpdf.pc
libnnpdf/src/NNPDF/common.h
libnnpdf/src/NNPDF/config.h
Expand Down
60 changes: 6 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ option(ENABLE_OPENMPI "Enable openMPI parallelism." OFF)
option(ENABLE_TESTS "Enable unit test" OFF)
option(ENABLE_ASAN "Enable ASAN" OFF)
option(ENABLE_DEAD_STRIP "Enable use of flag `-dead_strip-dylibs`" OFF)
option(VP_DEV "validphys in developer mode" ON)
option(N3_DEV "n3fit in developer mode" ON)
option(BURN_TAG "burn down the git tag in vp and n3fit (only local non-dev installation)" ON)
option(NNPDF_DEV "n3fit and validphys in developer mode" ON)
set(PROFILE_PREFIX "" CACHE STRING "Where you store the 'data' folder. Default empty uses CMAKE_INSTALL_PREFIX/share/NNPDF.")

if (PROFILE_PREFIX)
Expand Down Expand Up @@ -148,54 +146,8 @@ add_subdirectory(nnpdfcpp)
# evolven3fit
add_subdirectory(n3fit/evolven3fit)

if((BURN_TAG) AND (NOT (VP_DEV) OR NOT (N3_DEV)))
# Find out where is the root of the git repository (if available) and finds the correct tag to burn down
# in the package. This just sets the variable, the actual burning is done down below by the validphys
# or n3fit installation and is found in the version.cmake file as it needs to be done post-installation
set(GIT_DIR "--git-dir=${PROJECT_SOURCE_DIR}/.git")
# get the current tag (ex: 3.4) and check at the same time whether git is available and the .git folder found
execute_process(COMMAND git ${GIT_DIR} describe --abbrev=0 --tags OUTPUT_VARIABLE GIT_TAG ERROR_VARIABLE GIT_ERROR)
if(GIT_ERROR STREQUAL "")
string(STRIP ${GIT_TAG} GIT_TAG)
# get the number of revisions since tag happened
execute_process(COMMAND git ${GIT_DIR} rev-list ${GIT_TAG}..HEAD --count OUTPUT_VARIABLE GIT_REVN)
string(STRIP ${GIT_REVN} GIT_REVN)
# get the shortname for the hash
execute_process(COMMAND git ${GIT_DIR} rev-parse --short HEAD OUTPUT_VARIABLE GIT_HASH)
string(STRIP ${GIT_HASH} GIT_HASH)
# find out whether the repository is in a dirty state
# (this returns ${GIT_TAG}-dev so we have to remove the tag)
execute_process(COMMAND git ${GIT_DIR} describe --abbrev=0 --tags --dirty=-dev OUTPUT_VARIABLE GIT_DIRTY)
string(STRIP ${GIT_DIRTY} GIT_DIRTY)
string(REPLACE "${GIT_TAG}" "" GIT_DIRTY ${GIT_DIRTY})
# now concatenate everything
# with the format ex: 3.4.1880+g00b1741c-dev
set(GIT_VERSION "build_version='${GIT_TAG}.${GIT_REVN}+g${GIT_HASH}${GIT_DIRTY}'")
# now set the variable at install time
install(CODE "set(GIT_VERSION \"${GIT_VERSION}\")")
else(GIT_ERROR STREQUAL "")
set(BURN_TAG OFF)
endif(GIT_ERROR STREQUAL "")
endif()

# install validphys2
if(VP_DEV)
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/validphys2)")
else(VP_DEV)
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/validphys2)")
if(BURN_TAG)
install(CODE "set(LIBRARY \"validphys\")")
install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake)
endif(BURN_TAG)
endif(VP_DEV)

# install n3fit
if(N3_DEV)
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -e ${PROJECT_SOURCE_DIR}/n3fit)")
else(N3_DEV)
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR}/n3fit)")
if(BURN_TAG)
install(CODE "set(LIBRARY \"n3fit\")")
install(SCRIPT ${PROJECT_SOURCE_DIR}/version.cmake)
endif(BURN_TAG)
endif(N3_DEV)
if(NNPDF_DEV)
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps -e ${PROJECT_SOURCE_DIR})")
else(NNPDF_DEV)
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps --ignore-installed ${PROJECT_SOURCE_DIR})")
endif(NNPDF_DEV)
5 changes: 1 addition & 4 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

mkdir build
cd build
echo "build_version=\"${PKG_VERSION}\"" > ../n3fit/src/n3fit/version.py
echo "build_version=\"${PKG_VERSION}\"" > ../validphys2/src/validphys/version.py

cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DVP_DEV=OFF -DN3_DEV=OFF -DBURN_TAG=OFF
cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DNNPDF_DEV=OFF
make -j${CPU_COUNT}
make install
2 changes: 2 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ requirements:
- apfel >=3 # see https://github.com/scarrazza/apfel
- python
- numpy
- poetry-core >=1.0.0
- poetry-dynamic-versioning >=1.1.0
run:
- tensorflow >=2.10
- tensorflow >=2.10 *eigen* # [py < 311]
Expand Down
22 changes: 11 additions & 11 deletions doc/sphinx/source/data/data-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
Organisation of data files
==========================

The ``nnpdf++`` code needs to be able to handle a great deal of different
The ``nnpdf`` code needs to be able to handle a great deal of different
options with regard to the treatment of both experimental data and theoretical
choices. In the code, every effort has been made to keep experimental and
theoretical parameters strictly separate.
In this section we shall specify the layout of the various ``nnpdf++`` data
In this section we shall specify the layout of the ``nnpdf`` data
directory. It is in this directory that all of the read-only data to be used in
the fit are accessed. The data directory is located in the ``nnpdfcpp`` git
repository, under the path ``/nnpdfcpp/data/``.
the fit are accessed. The data directory is located in the ``nnpdf`` git
repository, under the path ``validphys/src/validphys2/datafiles``.

Experimental data storage
=========================

The central repository for ``CommonData`` in use by ``nnpdf++`` projects is
located in the ``nnpdfcpp`` git repository at
The central repository for ``CommonData`` in use by ``nnpdf`` projects is
located in the ``nnpdf`` git repository at

``/nnpdfcpp/data/commondata/``
``validphys/src/validphys2/datafiles/commondata``

where a separate ``CommonData`` file is stored for each *Dataset* with the
filename format
Expand All @@ -29,7 +29,7 @@ filename format
Information on the treatment of systematic uncertainties, provided in
``SYSTYPE`` files, is located in the subdirectory

``/nnpdfcpp/data/commondata/systypes``
``commondata/systypes``

Here several ``SYSTYPE`` files may be supplied for each *Dataset*. The
various options are enumerated by suffix to the filename. The filename format
Expand All @@ -47,16 +47,16 @@ Theory lookup table

In order to organise the various different theoretical treatments available, a
lookup table is provided in ``sqlite3`` format. This lookup table can be found
in the ``nnpdfcpp`` repository data directory at:
in the ``nnpdf`` repository data directory at:

``/nnpdfcpp/data/theory.db``
``validphys/src/validphys2/datafiles/theory.db``

This file should only be edited in order to add new theory options. It may be
edited with any appropriate ``sqlite3``-supported software. A script is provided to
give a brief overview of the various theory options available. It can be found
at

``/nnpdfcpp/data/disp_theory.py``
``validphys/src/validphys2/datafiles/disp_theory.py``

and should be run without any arguments.

Expand Down
6 changes: 3 additions & 3 deletions doc/sphinx/source/theory/theoryparamsinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
```
# Looking up the parameters of a theory

The parameters for all of the theories can be found in the `theory.db` file,
located in the `<NNPDF install location>/share/NNPDF/data` directory. This is an
sqlite database file. The information contained within this file can also be
The parameters for all of the theories can be found in the `theory.db` file.
The `theory.db` file is installed together as part of the validphys package.
This is an sqlite database file. The information contained within this file can also be
viewed [within the docs](theory-indexes).

The tools required to extract the parameters for a given theory are already in
Expand Down
45 changes: 26 additions & 19 deletions doc/sphinx/source/vp/nnprofile.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@
The `nnprofile.yaml` file
=========================

The NNPDF code (both `libnnpdf` and `validphys`) stores some configuration
options (mostly various URLs and paths) in an `nnprofile.yaml` file, which is
installed with the code.
The NNPDF code stores some configuration options (mostly various URLs and paths) in a `.yaml` file
which is installed alongside the code.
The default values can be consulted in ``validphys/default_nnprofile.yaml``.

In particular this configuration is used by `validphys` to locate,
This configuration is used by `validphys` to locate,
[upload](upload) and [download](download) resources.

Altering profile settings
--------------------------

The default settings are computed based on the install prefix, from the input
file `libnnpdf/nnprofile.yaml.in`. Changes with the intention to affect all uses
(such as adding a new repository for PDF sets) should be made there.

The default location of the profile file is computed at install time as
`$(INSTALL_PREFIX)/share/NNPDF/nnprofile.yaml`. The default profile is written
in that location and the code loads it from there. Users should not override
that installed file since changes to it will be lost the next time the code is
installed. However it is possible to alter the profile search location locally
by defining the environment variable ``NNPDF_PROFILE_PATH`` to point to a
different profile file, which will be loaded instead by the code. Specifying a
custom profile could be useful to add repositories for specific projects or
It is possible to set up a custom profile file in:
```
${XDG_CONFIG_HOME}/NNPDF/nnprofile.yaml
```
such that it will be used by every NNPDF installation (note that `${XDG_CONFIG_HOME}` defaults to `~/.config`)
or by defining the environment variable ``NNPDF_PROFILE_PATH`` to point to a
different profile file, which will be loaded instead by the code.
Specifying a custom profile could be useful to add repositories for specific projects or
change the paths based on the local filesystem characteristics.

If a custom profile is used, the values defined there will take precedence over the default values defined by NNPDF.

Options
-------

Expand All @@ -37,13 +35,22 @@ the code. These should be specified in YAML format.

```eval_rst

``data_path``
The path in the user's system where input data such as CommonData files and
FKtables are to be found, and stored when :ref:`downloaded <download>`.
``nnpdf_share```
Main folder for NNPDF shared resources: theories, fits, hyperscans, etc.
Ex: ``nnpdf_share: ~/.local/share/NNPDF``.
All other paths are defined relative to ``nnpdf_share``.
It is possible to set the special key ``RELATIVE_TO_PYTHON``, in this case the code
will use as share folder the share folder of the current environment (for instance ``${CONDA_PREFIX}/share/NNPDF``).

``theories_path``
The path in the user's system where the theory files (FKtables and ekos)
are to be found, and stored when :ref:`downloaded <download>`.
Defaults to ``nnpdf_share/theories``.

``results_path``
A path where completed fits are to be retrieved from,
and stored when :ref:`downloaded <download>`.
Defaults to ``nnpdf_share/results``.

``validphys_cache_path``
A path where to store downloaded validphys resources.
Expand Down
7 changes: 4 additions & 3 deletions doc/sphinx/source/vp/scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ Will result in a fit named :code:`181109-si-nlo-central_DISonly` and a copy name
in the original directory.

However, by default, fits that are download with :code:`vp-get fit` will be located in the NNPDF
results directory. This is usually located in
:code:`~/miniconda3/envs/<nnpdf env>/share/NNPDF/results`. Fits located in this directory can be
renamed with the :code:`-r` flag.
results directory.
The results directory is defined by the ``results_path`` key in the ``nnprofile.yaml`` configuration file
(usually located in ``~/.config/NNPDF/nnprofile.yaml``).
Fits located in this directory can be renamed with the :code:`-r` flag.

As an example, suppose the fit :code:`181109-si-nlo-central_DISonly` is located in the NNPDF
results directory. It can be renamed, irrespective of the current working directory, using
Expand Down
3 changes: 3 additions & 0 deletions libnnpdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ target_link_libraries(nnpdf ${LHAPDF_LIBRARIES} ${GSL_LDFLAGS} ${SQLITE3_LDFLAGS

install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/scripts/nnpdf.pc DESTINATION lib/pkgconfig)
install(DIRECTORY src/NNPDF DESTINATION include)

file(WRITE ${PROJECT_SOURCE_DIR}/libnnpdf/REAMDE.md "The share folder of NNPDF has been moved, see: https://github.com/NNPDF/nnpdf/pull/1861\n")
install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/REAMDE.md DESTINATION share/NNPDF)
Comment on lines +62 to +63
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file(WRITE ${PROJECT_SOURCE_DIR}/libnnpdf/REAMDE.md "The share folder of NNPDF has been moved, see: https://github.com/NNPDF/nnpdf/pull/1861\n")
install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/REAMDE.md DESTINATION share/NNPDF)
file(WRITE ${PROJECT_SOURCE_DIR}/libnnpdf/README.md "The share folder of NNPDF has been moved, see: https://github.com/NNPDF/nnpdf/pull/1861\n")
install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/README.md DESTINATION share/NNPDF)

install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/nnprofile.yaml DESTINATION share/NNPDF)
install(TARGETS nnpdf DESTINATION lib)

Expand Down
22 changes: 0 additions & 22 deletions libnnpdf/README.md

This file was deleted.

1 change: 0 additions & 1 deletion n3fit/evolven3fit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ target_link_libraries(evolven3fit nnpdf ${YAML_LDFLAGS} ${APFEL_LIBRARIES} ${GSL
install(TARGETS evolven3fit DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

21 changes: 0 additions & 21 deletions n3fit/setup.py

This file was deleted.

1 change: 1 addition & 0 deletions n3fit/src/evolven3fit_new/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from validphys._version import __version__
3 changes: 1 addition & 2 deletions n3fit/src/n3fit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from n3fit.version import build_version
__version__ = build_version
from validphys._version import __version__
41 changes: 0 additions & 41 deletions n3fit/src/n3fit/version.py

This file was deleted.

10 changes: 0 additions & 10 deletions nnpdfcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,5 @@ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/binaries)
# execute project specific targets
add_subdirectory(src)

# install data
install(DIRECTORY ${PROJECT_SOURCE_DIR}/nnpdfcpp/data/ DESTINATION ${PROFILE_PREFIX}/data/ MESSAGE_NEVER)

# install results
install(DIRECTORY DESTINATION ${PROFILE_PREFIX}/results/)
install(DIRECTORY DESTINATION ${PROFILE_PREFIX}/hyperscan_results/)

file(WRITE ${PROJECT_BINARY_DIR}/nnpdfcpp/README.md "Store here your fit output.")
install(FILES ${PROJECT_BINARY_DIR}/nnpdfcpp/README.md DESTINATION ${PROFILE_PREFIX}/results/)

# install configs
install(DIRECTORY ${PROJECT_SOURCE_DIR}/nnpdfcpp/config/ DESTINATION ${PROFILE_PREFIX}/config/)
17 changes: 0 additions & 17 deletions nnpdfcpp/README.md

This file was deleted.

Loading