Skip to content

Commit 201bdc1

Browse files
paulf81paulf81genevievestarke
authored
Standardize ruff to precommit (#245)
* update ruff in precommit * remove isort * remove seperate ruff check and use precommit in ci * pre-commit linting * Add contribution docs page with pre-commit install instructions --------- Co-authored-by: paulf81 <paul.fleming@nrel.gov> Co-authored-by: Genevieve Starke <genevieve.starke@nrel.gov>
1 parent 7697da9 commit 201bdc1

58 files changed

Lines changed: 215 additions & 274 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ updates:
99
- "package"
1010
ignore:
1111
- dependency-name: "*"
12-
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
12+
update-types: ["version-update:semver-minor", "version-update:semver-patch"]

.github/workflows/continuous-integration-workflow.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ jobs:
2222
run: |
2323
python -m pip install --upgrade pip
2424
pip install -e ".[develop]"
25-
# - uses: pre-commit/action@v3.0.0
26-
- name: Run ruff
27-
run: |
28-
ruff check .
29-
ruff format --check
25+
- uses: pre-commit/action@v3.0.0
26+
if: matrix.python-version == '3.13'
3027
- name: Run tests and collect coverage
3128
run: |
3229
# -rA displays the captured output for all tests after they're run

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repos:
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
1717
# Ruff version.
18-
rev: v0.1.7
18+
rev: v0.15.8
1919
hooks:
2020
# Run the linter.
2121
- id: ruff

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
2323
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
2424
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2525
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26-
POSSIBILITY OF SUCH DAMAGE.
26+
POSSIBILITY OF SUCH DAMAGE.

docs/_config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,3 @@ html:
3737
use_edit_page_button: true
3838
analytics:
3939
google_analytics_id: G-3V1BDK8KEJ
40-
41-
42-
Lines changed: 15 additions & 15 deletions
Loading

docs/battery.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Battery
22

3-
There are two battery models currently implemented in Hercules: `BatterySimple` and `BatteryLithiumIon`.
3+
There are two battery models currently implemented in Hercules: `BatterySimple` and `BatteryLithiumIon`.
44

55
## Sign Conventions
66

7-
It is important to note that within the battery modules, the convention that positive power is charging the
7+
It is important to note that within the battery modules, the convention that positive power is charging the
88
battery is followed for consistency with battery standards. However, at the level of the `HybridPlant`
99
this is inverted, such that positive power implies power delivery (and thus the battery is discharging)
1010
for consistency with other components. This inversion applies to power_setpoint and also occurs within
@@ -53,14 +53,14 @@ h_dict = {
5353

5454
### Outputs
5555
Outputs are returned as a dict containing the following values:
56-
- `power`: Actual battery power in kW
56+
- `power`: Actual battery power in kW
5757
- `reject`: Rejected power due to constraints in kW (positive when power cannot be absorbed, negative when required power unavailable)
5858
- `soc`: Battery state of charge (0-1)
5959
- `power_setpoint`: Requested power setpoint in kW
6060

6161
#### Additional Outputs (BatterySimple only when track_usage=True)
6262
- `usage_in_time`: Time-based usage percentage
63-
- `usage_in_cycles`: Cycle-based usage percentage
63+
- `usage_in_cycles`: Cycle-based usage percentage
6464
- `total_cycles`: Total equivalent cycles completed
6565

6666
(battery-logging-configuration)=

docs/contribute.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing to Hercules
2+
3+
We welcome contributions in the form of bug reports, bug fixes, improvements to the documentation,
4+
ideas for enhancements (or the enhancements themselves!).
5+
6+
You can find a [list of current issues](https://github.com/NatLabRockies/hercules/issues) in the project's
7+
GitHub repo. Feel free to tackle any existing bugs or enhancement ideas by submitting a
8+
[pull request](https://github.com/NatLabRockies/hercules/pulls).
9+
10+
11+
## Pull Requests
12+
If you'd like to contribute code through a pull request, please read the following guidance:
13+
* Please reference relevant GitHub issues in your commit message using `GH123` or `#123`.
14+
* Changes should be [PEP8](http://www.python.org/dev/peps/pep-0008/) compatible.
15+
* Keep style fixes to a separate commit to make your pull request more readable.
16+
* Docstrings are required and should follow the
17+
[Google style](https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html).
18+
* When you start working on a pull request, start by creating a new branch pointing at the latest
19+
commit on [develop](https://github.com/NatLabRockies/hercules/tree/develop).
20+
* Code formatting is enforced using pre-commit hooks and is required for any code pushed up to the repository. The pre-commit package is included in the developer install of the repository. The pre-commit hooks can be installed by running
21+
```bash
22+
pre-commit install
23+
```
24+
in the repository directory. This will automatically run the pre-commit formatting hooks when code changes are committed. If you are having difficulty committing code after it has been reformatted by these hooks, try using the commit command
25+
```bash
26+
git commit -am "<Your commit message here>"
27+
```
28+
which will re-add the reformatted files to the commit.
29+
If changes are required, follow the suggested fix or resolve the stated issue(s). Restaging and committing may take multiple attempts steps if errors are unaddressed or insufficiently addressed. Please see [pre-commit](https://pre-commit.com/),
30+
[ruff](https://docs.astral.sh/ruff/), or [isort](https://pycqa.github.io/isort/) for more information.
31+
* The Hercules copyright policy is detailed in the [`LICENSE`](https://github.com/NatLabRockies/hercules/blob/main/LICENSE.txt).

docs/electrolyzer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ The parameters listed below are required unless otherwise specified as *Optional
4646
- `eol_eff_percent_loss`: End of life efficiency percent loss [%].
4747
- `PEM_params` or `ALK_params`: Degradation parameters specific to PEM or Alkaline cells:
4848
- `rate_steady`: Rate of voltage degradation under steady operation alone
49-
- `rate_fatigue`: Rate of voltage degradation under variable operation alone
49+
- `rate_fatigue`: Rate of voltage degradation under variable operation alone
5050
- `rate_onoff`: Rate of voltage degradation per on/off cycle
5151
- `controller`: Electrolyzer control parameters including:
5252
- `control_type`: Controller type for electrolyzer plant operation.
5353
- `costs`: *Optional* Cost parameters for the electrolyzer plant including:
5454
- `plant_params`:
5555
- `plant_life`: integer, Plant life in years
56-
- `pem_location`: Location of the PEM electrolyzer. Options are
56+
- `pem_location`: Location of the PEM electrolyzer. Options are
5757
[onshore, offshore, in-turbine]
5858
- `grid_connected`: boolean, Whether the plant is connected to the grid or not
5959
- `feedstock`: Parameters related to the feedstock including:
6060
- `water_feedstock_cost`: Cost of water per kg of water
6161
- `water_per_kgH2`: Amount of water required per kg of hydrogen produced
6262
- `opex`: Operational expenditure parameters including:
63-
- `var_OM`: Variable operation and maintenance cost per kW
63+
- `var_OM`: Variable operation and maintenance cost per kW
6464
- `fixed_OM`: Fixed operation and maintenance cost per kW-year
6565
- `stack_replacement`: Parameters related to stack replacement costs including:
6666
- `d_eol`: End of life cell voltage value [V]

docs/examples/00_wind_farm_only.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ To plot the outputs, run the following command in the terminal:
2222

2323
```bash
2424
python plot_outputs.py
25-
```
25+
```

0 commit comments

Comments
 (0)