Skip to content

Commit

Permalink
docs.ruleset update process
Browse files Browse the repository at this point in the history
  • Loading branch information
tab1tha committed Jun 2, 2023
1 parent 83ec31a commit e6a0572
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,22 @@ If it is cloned locally, use `pre-commit install` to install the pre-commit hook
`python -m cin_validator xmltocsv <path to test data>`

## Yearly tool updates
- Run ` python get_uk_holidays.py` in the command line. This fetches the latest values of bank holidays into `cin_validator\england_holidates.py` (don't edit this file directly) for the rules that need them. Remember to convert \ to / if you are using a unix operating system.

### update rule resources
- Run ` python get_uk_holidays.py` in the command line. This fetches the latest values of bank holidays into `cin_validator\england_holidates.py` (don't edit this file directly) for the rules that need them. Remember to convert \ to / if you are using a unix operating system.

### update rules
- If any rules have been added or changed with respect to the previous year, create files for them in a rule folder named after the new validation year. For example, new or added rules for the 2023/24 validation year should be created in a folder named `cin2023_24`. Do not copy over rules that haven't changed.
- Follow the instructions in `cin_validator\ruleset.py`. This step ensures that your folder (containing the recent rule updates) is linked to the previous years and can inherit those rules which haven't changed. It will automatically sync even if more rules are added to the folder later.
- If any rules have been deleted, do not delete the rule files from the previous year. Instead, add the rule codes *as strings* to the corresponding list in `cin_validator\ruleset.py`. For example, if the specification of 2023/24 states that few rules which were present in the previous year should no longer be considered - edits should be done on this line `ruleset_updates["cin2023_24"] = {"deleted": [], "ruleset": cin23_24}`.
- Update ruleset defaults in `cin_validator\__main__.py` by updating `default="cin2022_23"` to that of the relevant year. For example, for the year 2023/24 use `default="cin2023_24"`

## make changes available to user
- delete the `dist` folder completely.
- run `poetry install` (installs project dependencies) and then `poetry shell` (ensures project runs in controlled environment) in the command line. You might have already done this when updating the rules.
- check that validation rules work as expected (pass) when you run `poetry python -m cin_validator test` in the command line.
- Then run `poetry build` in the command line. You will see that this creates a new `dist` folder.
- take the `.whl` file from the dist folder in this repo, go to the `public\bin\dist` location in the frontend repo, delete the cin...whl file in it and add this one.
- Do a pull request to the frontend repo, containing your changes. When that is merged in, the tool will be updated automatically so that your rules updates from the backend (which were zipped up in the wheel file), are now publicly available.
- You can watch the deployment process in the `Actions` tab on Github when your pull request is merged to the frontend.
- All done !
8 changes: 5 additions & 3 deletions cin_validator/ruleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
ruleset_updates = {}
ruleset_years = []

# get rulesets for each year as a dictionary. Chronological order should be maintained.
# get rulesets for each year as a dictionary.
# Chronological order must be maintained when adding rulesets to this file.

# 2022_23
import cin_validator.rules.cin2022_23
Expand All @@ -21,10 +22,11 @@
ruleset_years.append("cin2023_24")
registry.reset()


# Create customised registry object based on year specified.
# 2024_25
# create a duplicate of the code block above and edit the year values to suit this year.


# Create customised registry object based on year specified.
def create_registry(ruleset=ruleset_years[-1]):
"""
:param str ruleset: year whose version of rules should be run. e.g cin2022_23.
Expand Down

0 comments on commit e6a0572

Please sign in to comment.