Imperial DIRAC Development

From GridPP Wiki
Jump to: navigation, search

So you need to patch things .....

Installing UI in development mode

Example: Testing the branch 'comdirac_merge' agaist diracdev.

git clone git@github.com:ic-hep/DIRAC.git
cd DIRAC
git checkout comdirac_merge
cd ..
curl -LO https://github.com/DIRACGrid/DIRACOS2/releases/latest/download/DIRACOS-Linux-$(uname -m).sh
bash DIRACOS-Linux-$(uname -m).sh
rm DIRACOS-Linux-$(uname -m).sh
source diracos/diracosrc
pip install -e DIRAC
dirac-proxy-init -x -N
dirac-configure -F -S GridPP -C dips://diracdev.grid.hep.ph.ic.ac.uk:9135/Configuration/Server -I


Building readthedocs locally

source diracos/diracosrc
cd DIRAC/docs/source
micromamba create -n docs -f environment.yml
micromamba activate docs
export READTHEDOCS=True
python -m sphinx -T -E -W --keep-going -b html -d _build/doctrees -D language=en . _build/html

When finished copy the html directory somewhere easily accessible by the internet.


pylint

pylint-3 --rcfile .pylintrc src/DIRAC/Interfaces/scripts/dls.py

Not ideal, but will catch most problems.


Blacking your files (low key approach)

File to be formatted: src/DIRAC/Interfaces/scripts/dls.py This is for v8 onwards, so we are only interested in py3.

source diracos/diracosrc
cd DIRAC
git status
(Find files you want to black. Do a commit if you think black might mangle your files beyond recovery.)
pip install black (if not done previously)
black -t py39 -l 120 src/DIRAC/Interfaces/scripts/dls.py 
if black has reformatted your file:
git diff src/DIRAC/Interfaces/scripts/dls.py 

All good ? Now push your changes back to git.


New as of Oct 2022: pyupgrade

source diracos/diracosrc
(if not installed:) pip install pyupgrade

check in .pre-commit-config.yaml for options

(base) lxxx:DIRAC > pyupgrade --py39-plus src/DIRAC/Interfaces/scripts/dls.py 
Rewriting src/DIRAC/Interfaces/scripts/dls.py
git diff src/DIRAC/Interfaces/scripts/dls.py

Now decide whether to accept the re-write or do something even more clever.


Committing code back to DIRAC

A note on DIRAC commit messages: These must start with "fix:", "feat:" or "docs:".

Pull requests must start with the release in [] in the title: "[8.0] Make everything better".

If you need to amend a 'faulty' commit message in DIRAC (assuming this was the last commit)

git rebase -i HEAD^
amend 'pick' to 'reword' (do not change the message)
this will re-open commit message: edit and save
git push --force

Re-basing your code, simplest case
Make sure your upstream is set correctly, if not set it:

git remote add upstream https://github.com/DIRACGrid/DIRAC.git
git remote -v
origin  git@github.com:ic-hep/DIRAC.git (fetch)
origin  git@github.com:ic-hep/DIRAC.git (push)
upstream        https://github.com/DIRACGrid/DIRAC.git (fetch)
upstream        https://github.com/DIRACGrid/DIRAC.git (push)

You must fetch your upstream before doing anything:

git fetch upstream

In the simplest case, i.e. you are developing against rel-v8r0 and just need to re-base against the most up to date version of this branch:

git rebase upstream/rel-v8r0
Successfully rebased and updated refs/heads/comdirac_merge

Afterwards git status should look approximately like this:

(base) lx04:DIRAC > git status
On branch comdirac_merge
Your branch and 'origin/comdirac_merge' have diverged,
and have 103 and 9 different commits each, respectively.

Now push it back:

git push -f

and check the branch on github to make sure it all still looks reasonable. (If it doesn't, blame Simon and ask him to fix it.)