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

Update installation for support m2 mac #337

Merged
merged 7 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ jobs:
- name: Running pylint
shell: bash -l {0}
run: |
pylint firecrown
pylint --rcfile tests/pylintrc tests
pylint --rcfile firecrown/models/pylintrc firecrown/models
pylint firecrown
- name: Running pytest
shell: bash -l {0}
run: python -m pytest -vv
Expand Down
89 changes: 1 addition & 88 deletions docs/apple_m1_instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,92 +4,5 @@ Instructions for installation of Firecrown on Apple M1 and M2 hardware
.. role:: bash(code)
:language: bash

The ability to install Firecrown on Apple M1 and M2 hardware (not on Intel hardware) is currently incomplete because of difficulties in obtaining a consistent build of the CosmoSIS Standard Library on M1 and M2 Macs, and the unavailability of an M1 or M2 build of CosmoSIS through conda.
Until this is fixed, we recommend the following procedure.

.. note::
Special directions are no longer needed for installation of Firecrown on Apple M1 and M2 hardware.


This procedure is *not* recommended for other platforms.
It involves *building* the "head" versions of CosmoSIS and using (parts of) the "head" version of the CosmoSIS Standard Library.
The normal installation instructions give you a specified version known to be consistent with the rest of the code.
In addition, because this involves *building* CosmoSIS code, if you have something else in your environment that is accidentally found by the build, you may encounter a difficult-to-debug build failure, or worse yet a subtly inconsistent build that will perform incorrectly only some of the time.

Note that this installation procedure will give you an environment in which you have a copy of the Firecrown code and can do development, including producing pull requests to submit code back to Firecrown.

To do development work on Firecrown you need both the Firecrown source code and all the packages upon which Firecrown depends or is used with.
To get the Firecrown source code you will need to clone the Firecrown repository.
Most (but not all) of the dependencies of Firecrown are available through conda.
It is not currently possible to build the CosmoSIS Standard Library on M1 or M2 Macs.
However, you will be able to use the portions of the CosmoSIS Standard Library that do not require compilation.
This includes CAMB, but does not include many other modules.

These instructions include details on how to obtain the samplers used with Firecrown.
This is important because if you are doing development it is important to make sure what you change or add works with both of the supported samplers.

You only need to clone the Firecrown repository once, and to create the conda environment once.
Every time you want to do development in a new shell session you will need to activate the conda environment and set the environment variables.

Clone the Firecrown repository
==============================

Choose a directory in which to work.
In this directory, you will be cloning the Firecrown repository and later building some of the non-Firecrown code that is not installable through conda.

.. code:: bash

cd /directory/for/firecrown/work
git clone https://github.com/LSSTDESC/firecrown.git


Installation of dependencies
============================

These instructions will create a new conda environment containing all the packages used in development.
This includes testing and code verification tools used during the development process.

It is best to execute these commands while in the same directory as you were in when you cloned the Firecrown repository above.
Note that we do not build the CosmoSIS Standard Library.
Only the pure-python parts of the CSL will be available for use.

.. code:: bash

cd /directory/for/firecrown/work
conda create --name firecrown_developer -c conda-forge sacc pyccl fitsio fuzzywuzzy urllib3 PyYAML portalocker idna dill charset-normalizer requests matplotlib flake8 pylint black pytest coverage
conda activate firecrown_developer
export CC=clang CXX=clang++ FC=gfortran
python -m pip install cosmosis cobaya
source cosmosis-configure
git clone https://github.com/joezuntz/cosmosis-standard-library.git


Setting your environment for development
========================================

Each time you want to do development in a new shell session you need to activate the conda environment and set some environment variables.

Begin by `cd`-ing to the working directory you used during the installation (which should contain both `firecrown` and `cosmosis-standard-library` directories).

.. code:: bash

cd /directory/for/firecrown/work
conda activate firecrown_developer
export CSL_DIR=${PWD}/cosmosis-standard-library
export FIRECROWN_DIR=${PWD}/firecrown
export PYTHONPATH=${FIRECROWN_DIR}/build/lib

To build the Firecrown code you should be in the Firecrown directory:

.. code:: bash

cd ${FIRECROWN_DIR}
python setup.py build

The tests can be run with :bash:`pytest`, after building:

.. code:: bash

pytest

Examples can be run by `cd`-ing into the specific examples directory and following the instructions in the local README file.
Note that any example that uses a compiled module from the CosmoSIS Standard Library will fail.
4 changes: 1 addition & 3 deletions docs/basic_usage.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@


Using Firecrown
===============

The documentation for Firecrown is still under development.

There are examples in the `examples folder <https://github.com/LSSTDESC/firecrown/tree/master/examples>`_
that show some use of Firecrown with both Cobaya and CosmoSIS.
that show some use of Firecrown with all of the supported samplers.

28 changes: 16 additions & 12 deletions docs/contrib.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Contributing
============

Expand All @@ -7,15 +6,18 @@ Contributing

Contributions to Firecrown are welcome.

For any contribution, please start by `opening an issue <https://github.com/LSSTDESC/firecrown/issues>`_,
and using the GitHub interface to create a branch for that issue.
For any contribution, please start by `opening a discussion <https://github.com/LSSTDESC/firecrown/discussions>`_.
We are intending to use GitHub discussions to come to a consensus on the ideas for new additions.
Once a consensus is reached, we will convert the discussion into a GitHub issue that can be used to track the progress of the work.

New development for issues should be done on a branch.
To create a branch you will need write access; if you don't have write access, please send a request to the @LSSTDESC/firecrown-devs team.
You can also fork the repository and send a pull request from your fork.

When you have completed the task, push your commits to the branch you created for the issue and create a pull request.

We are using several tools to help keep the code tidy and correct; these are described below.
These tools are all applied by the continuous integration (CI) system that is run on every pull request.

Type checking
-------------
Expand All @@ -33,29 +35,31 @@ and fix any errors reported before pushing commits to the GitHub repository.
Testing
-------


.. warning::

We are working on improving the coverage of testing for Firecrown; it is currently very inadequate.
We are working on improving the coverage of testing for Firecrown; it is currently inadequate.
As the coverage improves, we will provide instructions for writing tests for new code.

We are using :bash:`pytest` to run tests on Firecrown.
Before running tests, one must first build the code.
In addition, the environment variable :bash:`PYTHONPATH` must be correctly set to run the tests.
Please see the instructions, above, for this setup.

Use of :bash:`pylint`
---------------------

We are using :bash:`pylint` to check for a variety of possible problems.
Firecrown is not currently "clean" of all :bash:`pylint` issues, so we are not yet using :bash:`pylint` in the CI testing.
`pylint` is run in the CI system with the following flags:

.. code:: bash

We are actively working on getting a "clean" report from :bash:`pylint`.
When this is achieved, we plan to activate :bash:`pylint` in the CI checking.
This will require that all new code pass :bash:`pylint`'s checks.
pylint firecrown
pylint --rcfile tests/pylintrc tests
pylint --rcfile firecrown/models/pylintrc firecrown/models

Code formatting
---------------

We are using the command-line tool :bash:`black` to auto-format Python code in Firecrown.
Please make sure to run black on your code before creating any commits.

.. code:: bash

black firecrown examples tests
20 changes: 11 additions & 9 deletions docs/dev-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ Developer Notes
.. role:: bash(code)
:language: bash

To run the current version, one needs to *build* (but not yet install) Firecrown.
In this directory, run:
To run the development version, one needs to do an *editable installation* of firecrown.
This will create an entry in the conda environment that knows about the local code.
You must have the `:bash:firecrown_developer` conda environment activated before running this installation.

python3 setup.py build
Note that we use the :bash:`--no-deps` flag to prevent the installation from accidentally taking in any new dependencies through :bash:`pip`.
If the installation fails because of the lack of a dependency, install that dependency using :bash:`conda` and not :bash:`pip`.
If you find a dependency on a package not available through :bash:`conda` please file an issue on the issue tracker.

This will put modules into the subdirectory :bash:`build/lib`.
Set the environment variable :bash:`FIRECROWN_DIR` to the full path to that directory.
Set the environment variable :bash:`FIRECROWN_EXAMPLES_DIR` to be the full path to the :bash:`examples` subdirectory.

These environment variables are needed by the example :bash:`ini` files.
The directory :bash:`$FIRECROWN_DIR` should also be on :bash:`PYTHONPATH`.
.. code:: bash

python -m pip install --no-deps --editable ${PWD}
vitenti marked this conversation as resolved.
Show resolved Hide resolved

Some of the examples and tests depend on the environment variables :bash:`FIRECROWN_DIR` and :bash:`CSL_DIR`.
These environment variables are defined for you every time you activate the conda environment.
Loading
Loading