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

Format codebase and add format check to the CI #673

Merged
merged 2 commits into from
Apr 4, 2024
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
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style = "sciml"
9 changes: 9 additions & 0 deletions .github/workflows/format_suggestions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Format suggestions
on:
pull_request:

jobs:
code-style:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/julia-format@v2
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
introduce this parameter as cost of virtual charging and discharging to avoid unusual results (#608).
- New settings parameter, StorageVirtualDischarge, to turn storage virtual charging and discharging off if desired by the user (#638).
- Add module to retrofit existing resources with new technologies (#600).
- Formatted the code and added a format check to the CI pipeline (#673).

### Fixed
- Set MUST_RUN=1 for RealSystemExample/small_hydro plants (#517).
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<div align="center"> <img src="docs/src/assets/logo_readme.svg" height ="200"width="1000" alt="GenX.jl"></img></div>

[![CI](https://github.com/GenXProject/GenX/actions/workflows/ci.yml/badge.svg)](https://github.com/GenXProject/GenX/actions/workflows/ci.yml)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://genxproject.github.io/GenX.jl/dev)
[![DOI](https://zenodo.org/badge/368957308.svg)](https://zenodo.org/doi/10.5281/zenodo.10846069)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
| **Documentation** | **DOI** |
|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://genxproject.github.io/GenX.jl/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://genxproject.github.io/GenX.jl/dev) | [![DOI](https://zenodo.org/badge/368957308.svg)](https://zenodo.org/doi/10.5281/zenodo.10846069)

[![CI](https://github.com/GenXProject/GenX/actions/workflows/ci.yml/badge.svg)](https://github.com/GenXProject/GenX/actions/workflows/ci.yml) [![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle) [![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

## Overview
GenX is a highly-configurable, [open source](https://github.com/GenXProject/GenX/blob/main/LICENSE) electricity resource capacity expansion model
Expand Down
51 changes: 22 additions & 29 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ using Documenter
using GenX
import DataStructures: OrderedDict

DocMeta.setdocmeta!(GenX, :DocTestSetup, :(using GenX); recursive=true)
DocMeta.setdocmeta!(GenX, :DocTestSetup, :(using GenX); recursive = true)

pages = OrderedDict(
"Welcome Page" => [
pages = OrderedDict("Welcome Page" => [
"GenX: Introduction" => "index.md",
"Installation Guide" => "installation.md",
"Limitation of GenX" => "limitations_genx.md",
"Third Party Extensions" => "third_party_genx.md"
"Third Party Extensions" => "third_party_genx.md",
],
"Getting Started" => [
"Running GenX" => "Getting_Started/examples_casestudies.md",
Expand Down Expand Up @@ -51,7 +50,7 @@ pages = OrderedDict(
"Flexible Demand" => "Model_Reference/Resources/flexible_demand.md",
"Hydro" => [
"Hydro Reservoir" => "Model_Reference/Resources/hydro_res.md",
"Long Duration Hydro" => "Model_Reference/Resources/hydro_inter_period_linkage.md"
"Long Duration Hydro" => "Model_Reference/Resources/hydro_inter_period_linkage.md",
],
"Must Run" => "Model_Reference/Resources/must_run.md",
"Retrofit" => "Model_Reference/Resources/retrofit.md",
Expand All @@ -62,18 +61,18 @@ pages = OrderedDict(
"Long Duration Storage" => "Model_Reference/Resources/long_duration_storage.md",
"Storage All" => "Model_Reference/Resources/storage_all.md",
"Storage Asymmetric" => "Model_Reference/Resources/storage_asymmetric.md",
"Storage Symmetric" => "Model_Reference/Resources/storage_symmetric.md"
"Storage Symmetric" => "Model_Reference/Resources/storage_symmetric.md",
],
"Co-located VRE and Storage" => "Model_Reference/Resources/vre_stor.md",
"Thermal" => [
"Thermal" => "Model_Reference/Resources/thermal.md",
"Thermal Commit" => "Model_Reference/Resources/thermal_commit.md",
"Thermal No Commit" => "Model_Reference/Resources/thermal_no_commit.md"
"Thermal No Commit" => "Model_Reference/Resources/thermal_no_commit.md",
],
"Hydrogen Electrolyzers" => "Model_Reference/Resources/electrolyzers.md",
"Retrofit" => "Model_Reference/Resources/retrofit.md",
"Scheduled maintenance for various resources" => "Model_Reference/Resources/maintenance.md",
"Resource types" => "Model_Reference/Resources/resource.md"
"Resource types" => "Model_Reference/Resources/resource.md",
],
"Maintenance" => "Model_Reference/maintenance_overview.md",
"Policies" => "Model_Reference/policies.md",
Expand All @@ -88,46 +87,40 @@ pages = OrderedDict(
"Multi-Stage Modeling Introduction" => "Model_Reference/Multi_Stage/multi_stage_overview.md",
"Configure multi-stage inputs" => "Model_Reference/Multi_Stage/configure_multi_stage_inputs.md",
"Model multi stage: Dual Dynamic Programming Algorithm" => "Model_Reference/Multi_Stage/dual_dynamic_programming.md",
"Endogenous Retirement" => "Model_Reference/Multi_Stage/endogenous_retirement.md"
"Endogenous Retirement" => "Model_Reference/Multi_Stage/endogenous_retirement.md",
],
"Method of Morris" => "Model_Reference/methodofmorris.md",
"Utility Functions" => "Model_Reference/utility_functions.md",
],
"Public API Reference" => [
"Public API" => "Public_API/public_api.md",

],
"Public API" => "Public_API/public_api.md"],
"Third Party Extensions" => "additional_third_party_extensions.md",
"Developer Docs" => "developer_guide.md",
)
"Developer Docs" => "developer_guide.md")

# Build documentation.
# ====================

makedocs(;
modules=[GenX],
authors="Jesse Jenkins, Nestor Sepulveda, Dharik Mallapragada, Aaron Schwartz, Neha Patankar, Qingyu Xu, Jack Morris, Sambuddha Chakrabarti",
sitename="GenX.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://genxproject.github.io/GenX.jl/stable",
modules = [GenX],
authors = "Jesse Jenkins, Nestor Sepulveda, Dharik Mallapragada, Aaron Schwartz, Neha Patankar, Qingyu Xu, Jack Morris, Sambuddha Chakrabarti",
sitename = "GenX.jl",
format = Documenter.HTML(;
prettyurls = get(ENV, "CI", "false") == "true",
canonical = "https://genxproject.github.io/GenX.jl/stable",
assets = ["assets/genx_style.css"],
sidebar_sitename=false,
collapselevel=1
),
pages=[p for p in pages]
)
sidebar_sitename = false,
collapselevel = 1),
pages = [p for p in pages])

# Deploy built documentation.
# ===========================

deploydocs(;
repo="github.com/GenXProject/GenX.jl.git",
repo = "github.com/GenXProject/GenX.jl.git",
target = "build",
branch = "gh-pages",
devbranch = "main",
devurl = "dev",
push_preview=true,
push_preview = true,
versions = ["stable" => "v^", "v#.#.#", "dev" => "dev"],
forcepush = false,
)
forcepush = false)
13 changes: 13 additions & 0 deletions docs/src/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ GenX is an open-source project, and we welcome contributions from the community.

The following sections describe in more detail how to work with GenX resources and how to add a new resource to GenX.

## Style guide
GenX project follows the [SciML Style Guide](https://github.com/SciML/SciMLStyle). We encourage contributors to follow this style guide when submitting code changes to GenX. Before submitting a new PR, please run the following command to format a file or a directory:
```julia
julia> using JuliaFormatter
julia> format("path_to_directory", SciMLStyle(), verbose=true)
```
or
```julia
julia> using JuliaFormatter
julia> format("path_to_file.jl", SciMLStyle(), verbose=true)
```
The GitHub repository of GenX is configured to verify the code style of each PR and will automatically provide comments to assist you in formatting the code according to the style guide.

## GenX resources

In GenX, a resource is defined as an instance of a `GenX resource type`, a subtype of an `AbstractResource`. This allows the code to use multiple dispatch and define a common interface (behavior) for all resources in the code.
Expand Down
2 changes: 1 addition & 1 deletion example_systems/1_three_zones/Run.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
run_genx_case!(dirname(@__FILE__))
2 changes: 1 addition & 1 deletion example_systems/2_three_zones_w_electrolyzer/Run.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
run_genx_case!(dirname(@__FILE__))
2 changes: 1 addition & 1 deletion example_systems/3_three_zones_w_co2_capture/Run.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
run_genx_case!(dirname(@__FILE__))
2 changes: 1 addition & 1 deletion example_systems/4_three_zones_w_policies_slack/Run.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
run_genx_case!(dirname(@__FILE__))
2 changes: 1 addition & 1 deletion example_systems/6_three_zones_w_multistage/Run.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
run_genx_case!(dirname(@__FILE__))
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
run_genx_case!(dirname(@__FILE__))
2 changes: 1 addition & 1 deletion example_systems/9_IEEE_9_bus_DC_OPF/Run.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
run_genx_case!(dirname(@__FILE__))
Loading
Loading