This is the repository for the NSLS-II Facility API codebase.
In order to develop locally you will need to have a local MongoDB running.
This can be installed using your preferred method, a native install
or running a container work perfectly fine.
Once you have MongoDB up and running you then need to 'seed' the facility and beamline information that does not get pulled from any other source.
The files for the collections can be found within the /nsls2/software/dssi/nsls2core/nsls2core-development.tgz
-
Copy and unpack the archive into a directory (e.g.
nsls2core-development) to your development machine -
Import facility information into the local mongodb```
mongorestore --uri="mongodb://localhost:27017" --nsFrom=nsls2core-development.facilities --nsTo=nsls2core-development.facilities ./nsls2core-development/facilities.bson -
Import beamline information into the local mongodb
mongorestore --uri="mongodb://localhost:27017" --nsFrom=nsls2core-development.beamlines --nsTo=nsls2core-development.beamlines ./nsls2core-development/beamlines.bson
You will then need to create a .env file that contains the configuration (an example can also be found in the same
directory as the json files).
- Copy
/nsls2/software/dssi/nsls2core/.env.developmentto your local machine - Rename to
.envand place in thesrc/nsls2apidirectory in your cloned repo (in the same folder asmain.py) - Ensure that you have the
bnlroot.crtfile (which is deployed to all BNL managed machines) in the location specified within the.envfile.
This project uses ruff to format the code - in order to run the formatter simply type:
uvx ruff formatThis project uses ruff to check the code - in order to run the linter simply type:
uvx ruff checkThe project uses uv pip compile to manage the requirements.txt and requirements-dev.txt files.
In order to upgrade the packages versions you will need to simply run
uv pip compile requirements-dev.in --upgrade -o requirements-dev.txt
uv pip compile requirements.in --upgrade -o requirements.txt
Then in order to actually upgrade the packages
uv pip install -r requirements-dev.txt
uv pip install -r requirements.txt
Of course, you can drop the uv from these last commands if you want to wait longer.