-
Notifications
You must be signed in to change notification settings - Fork 5
Update to psy5 and document package #37
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
Merged
Changes from 22 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
d4547f6
Update documenter and formatter and add docstrings
kdayday dbbbf30
Run formatter
kdayday b3e2715
Add formulations and add and clean docstrings
kdayday 3d2c013
Fix Complentary typo
kdayday 0f4bc23
Diataxis and add tutorial infrastructure
kdayday 4da239a
Add docs cleanup github action
kdayday 07becfb
Draft psy5 updates
kdayday aa84db4
Specify initial conditions model to avoid errors for models with rese…
kdayday b0f253f
Extend validate_time_series
kdayday 4f24490
Add StorageDispatchWithReserves tests and update tests for PSI versio…
kdayday 46e7513
Bookkeeping -> StorageDispatchWithReserves
kdayday 4bfb4ca
IS, PSY, PSI, comment version updates
kdayday 46fc2da
Update input data in docstrings
kdayday f2cc7bf
Clean up extrefs and simplify
kdayday dd8d78d
Error if merchant model called without HybridSystem
kdayday 3434602
Remove redundant price utils, bug fixes, and in-progress day ahead ts…
kdayday 6ee4d2f
Remove dead code from test utils
kdayday 143fe9f
Remove system_to_file for PSI compat
kdayday 43925ec
Update merchant thermal costs for new fuel and cost formats and add P…
kdayday 323b743
Add Sienna.md from IS
kdayday 9561ffd
Remove docs todo
kdayday 10fae25
Remove HPS and SSS from test dependencies and remove dead test code
kdayday bcf63c7
Formatter
kdayday 8223583
Add pre-commit yaml
kdayday fee3a79
Docstring parameter clarifications and clean-up
kdayday 35138d7
Apply suggestions from code review
kdayday 94c1570
Apply literate changes from PF PR
kdayday 7aa1f50
Merge branch 'kd/psy5' of github.com:NREL-Sienna/HybridSystemsSimulat…
kdayday e6bbb58
Merge branch 'main' into kd/psy5
kdayday 6aa810e
Skip cleanup on forks
kdayday 720598f
Replace remaining nrel-sienna links
kdayday d8fd3d2
Fix bare catch blocks in _add_hybrid_renewable_da_time_series!
Copilot fb759f1
Fix interval horizon issues for PSI 0.34
kdayday adf7b82
Harden hybrid time series parameter naming for PSI 0.34
kdayday 24f8ab2
Update for directly attached multi-resolution time-series instead of …
kdayday 345183f
Fix docs links
kdayday 6ab0ab6
Fix extref
kdayday 2833d5b
PSI 0.35 compat and update cost definitions
kdayday 12ae686
bump dependencies
jd-lara 5cc977f
code correctness updates
jd-lara bf1dcb9
update the cycle ff
jd-lara e31c320
fix some docstrings
jd-lara aaf326f
fix some modeling errors
jd-lara f6046f8
fix objective function implementation
jd-lara 4cbe769
update decision models
jd-lara 130a883
improve testing
jd-lara 860a051
fix deps
jd-lara 732cf1a
add the claude.md file
jd-lara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| # Sienna Programming Practices | ||
|
|
||
| This document describes general programming practices and conventions that apply across all Sienna packages (PowerSystems.jl, PowerSimulations.jl, PowerFlows.jl, PowerNetworkMatrices.jl, InfrastructureSystems.jl, etc.). | ||
|
|
||
| ## Performance Requirements | ||
|
|
||
| **Priority:** Critical. See the [Julia Performance Tips](https://docs.julialang.org/en/v1/manual/performance-tips/). | ||
|
|
||
| ### Anti-Patterns to Avoid | ||
|
|
||
| #### Type instability | ||
|
|
||
| Functions must return consistent concrete types. Check with `@code_warntype`. | ||
|
|
||
| - Bad: `f(x) = x > 0 ? 1 : 1.0` | ||
| - Good: `f(x) = x > 0 ? 1.0 : 1.0` | ||
|
|
||
| #### Abstract field types | ||
|
|
||
| Struct fields must have concrete types or be parameterized. | ||
|
|
||
| - Bad: `struct Foo; data::AbstractVector; end` | ||
| - Good: `struct Foo{T<:AbstractVector}; data::T; end` | ||
|
|
||
| #### Untyped containers | ||
|
|
||
| - Bad: `Vector{Any}()`, `Vector{Real}()` | ||
| - Good: `Vector{Float64}()`, `Vector{Int}()` | ||
|
|
||
| #### Non-const globals | ||
|
|
||
| - Bad: `THRESHOLD = 0.5` | ||
| - Good: `const THRESHOLD = 0.5` | ||
|
|
||
| #### Unnecessary allocations | ||
|
|
||
| - Use views instead of copies (`@view`, `@views`) | ||
| - Pre-allocate arrays instead of `push!` in loops | ||
| - Use in-place operations (functions ending with `!`) | ||
|
|
||
| #### Captured variables | ||
|
|
||
| Avoid closures that capture variables causing boxing. Pass variables as function arguments instead. | ||
|
|
||
| #### Splatting penalty | ||
|
|
||
| Avoid splatting (`...`) in performance-critical code. | ||
|
|
||
| #### Abstract return types | ||
|
|
||
| Avoid returning `Union` types or abstract types. | ||
|
|
||
| ### Best Practices | ||
|
|
||
| - Use `@inbounds` when bounds are verified | ||
| - Use broadcasting (dot syntax) for element-wise operations | ||
| - Avoid `try-catch` in hot paths | ||
| - Use function barriers to isolate type instability | ||
|
|
||
| > Apply these guidelines with judgment. Not every function is performance-critical. Focus optimization efforts on hot paths and frequently called code. | ||
|
|
||
| ## Code Conventions | ||
|
|
||
| Style guide: <https://nrel-sienna.github.io/InfrastructureSystems.jl/stable/style/> | ||
|
|
||
| Formatter (JuliaFormatter): Use the formatter script provided in each package. | ||
|
|
||
| Key rules: | ||
|
|
||
| - Constructors: use `function Foo()` not `Foo() = ...` | ||
| - Asserts: prefer `InfrastructureSystems.@assert_op` over `@assert` | ||
| - Globals: `UPPER_CASE` for constants | ||
| - Exports: all exports in main module file | ||
| - Comments: complete sentences, describe why not how | ||
|
|
||
| ## Documentation Practices and Requirements | ||
|
|
||
| Framework: [Diataxis](https://diataxis.fr/) | ||
|
|
||
| Sienna guide: <https://nrel-sienna.github.io/InfrastructureSystems.jl/stable/docs_best_practices/explanation/> | ||
|
|
||
| Sienna guide for Diataxis-style tutorials: <https://nrel-sienna.github.io/InfrastructureSystems.jl/stable/docs_best_practices/how-to/write_a_tutorial/> | ||
| Format for tutorial scripts: <https://fredrikekre.github.io/Literate.jl/v2/> | ||
| Sienna guide for Diataxis-style how-to's: <https://nrel-sienna.github.io/InfrastructureSystems.jl/stable/docs_best_practices/how-to/write_a_how-to/> | ||
| Sienna guide for APIs: <https://nrel-sienna.github.io/InfrastructureSystems.jl/stable/docs_best_practices/how-to/write_docstrings_org_api/> | ||
|
|
||
| Docstring requirements: | ||
|
|
||
| - Scope: all elements of public interface (IS is selective about exports) | ||
| - Include: function signatures and arguments list | ||
| - Automation: `DocStringExtensions.TYPEDSIGNATURES` (`TYPEDFIELDS` used sparingly in IS) | ||
| - See also: add links for functions with same name (multiple dispatch) | ||
|
|
||
| API docs: | ||
|
|
||
| - Public: typically in `docs/src/api/public.md` using `@autodocs` with `Public=true, Private=false` | ||
| - Internals: typically in `docs/src/api/internals.md` | ||
|
|
||
| ## Design Principles | ||
|
|
||
| - Elegance and concision in both interface and implementation | ||
| - Fail fast with actionable error messages rather than hiding problems | ||
| - Validate invariants explicitly in subtle cases | ||
| - Avoid over-adherence to backwards compatibility for internal helpers | ||
|
|
||
| ## Contribution Workflow | ||
|
|
||
| **Note:** The default branch for all Sienna packages is `main`, not `master`. | ||
|
|
||
| Branch naming: `feature/description` or `fix/description` | ||
|
|
||
| 1. Create feature branch | ||
| 2. Follow style guide and run formatter | ||
| 3. Ensure tests pass | ||
| 4. Submit pull request | ||
|
|
||
| ## AI Agent Guidance | ||
|
|
||
| **Key priorities:** Read existing patterns first, maintain consistency, use concrete types in hot paths, run formatter, add docstrings to public API, ensure tests pass. | ||
|
|
||
| **Critical rules:** | ||
| - Always use `julia --project=<env>` (never bare `julia`) | ||
| - Never edit auto-generated files directly | ||
| - Verify type stability with `@code_warntype` for performance-critical code | ||
| - Consider downstream package impact | ||
|
|
||
| ## Julia Environment Best Practices | ||
|
|
||
| **CRITICAL:** Always use `julia --project=<env>` when running Julia code in Sienna repositories. **NEVER** use bare `julia` or `julia --project` without specifying the environment. Each package typically defines dependencies in `test/Project.toml` for testing. | ||
|
|
||
| Common patterns: | ||
|
|
||
| ```sh | ||
| # Run tests (using test environment) | ||
| julia --project=test test/runtests.jl | ||
|
|
||
| # Run specific test | ||
| julia --project=test test/runtests.jl test_file_name | ||
|
|
||
| # Run expression | ||
| julia --project=test -e 'using PackageName; ...' | ||
|
|
||
| # Instantiate environment | ||
| julia --project=test -e 'using Pkg; Pkg.instantiate()' | ||
|
|
||
| # Build docs (using docs environment) | ||
| julia --project=docs docs/make.jl | ||
| ``` | ||
|
|
||
| **Why this matters:** Running without `--project=<env>` will fail because required packages won't be available in the default environment. The test/docs environments contain all necessary dependencies for their respective tasks. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **Type instability** | ||
| - Symptom: Poor performance, many allocations | ||
| - Diagnosis: `@code_warntype` on suspect function | ||
| - Solution: See performance anti-patterns above | ||
|
|
||
| **Formatter fails** | ||
| - Symptom: Formatter command returns error | ||
| - Solution: Run the formatter script provided in the package (e.g., `julia -e 'include("scripts/formatter/formatter_code.jl")'`) | ||
|
|
||
| **Test failures** | ||
| - Symptom: Tests fail unexpectedly | ||
| - Solution: `julia --project=test -e 'using Pkg; Pkg.instantiate()'` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: Doc Preview Cleanup | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
|
|
||
| # Ensure that only one "Doc Preview Cleanup" workflow is force pushing at a time | ||
| concurrency: | ||
| group: doc-preview-cleanup | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| doc-preview-cleanup: | ||
| runs-on: ubuntu-latest | ||
| # This workflow pushes to gh-pages; permissions are per-job and independent of docs.yml | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout gh-pages branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: gh-pages | ||
| - name: Delete preview and history + push changes | ||
| run: | | ||
| if [ -d "${preview_dir}" ]; then | ||
| git config user.name "Documenter.jl" | ||
| git config user.email "documenter@juliadocs.github.io" | ||
| git rm -rf "${preview_dir}" | ||
| git commit -m "delete preview" | ||
| git branch gh-pages-new "$(echo "delete history" | git commit-tree "HEAD^{tree}")" | ||
| git push --force origin gh-pages-new:gh-pages | ||
| fi | ||
| env: | ||
| preview_dir: previews/PR${{ github.event.number }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # Contributing | ||
|
|
||
| Community driven development of this package is encouraged. To maintain code quality standards, please adhere to the following guidlines when contributing: | ||
|
kdayday marked this conversation as resolved.
Outdated
|
||
| - To get started, <a href="https://www.clahub.com/agreements/NREL/SIIP-PACKAGE.jl">sign the Contributor License Agreement</a>. | ||
| - Please do your best to adhere to our [coding style guide](docs/src/developer/style.md). | ||
| - To submit code contributions, [fork](https://help.github.com/articles/fork-a-repo/) the repository, commit your changes, and [submit a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). | ||
|
|
||
| - To get started, <a href="https://www.clahub.com/agreements/NREL/SIIP-PACKAGE.jl">sign the Contributor License Agreement</a>. | ||
| - Please do your best to adhere to our [coding style guide](docs/src/developer/style.md). | ||
| - To submit code contributions, [fork](https://help.github.com/articles/fork-a-repo/) the repository, commit your changes, and [submit a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| [deps] | ||
| DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
| DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | ||
| Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
| DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" | ||
| DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8" | ||
| HybridSystemsSimulations = "bed98974-b02a-5e2f-9ee0-a103f5c450dd" | ||
| Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" | ||
| PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" | ||
|
|
||
| [compat] | ||
| Documenter = "0.27" | ||
| Documenter = "1.0" | ||
| julia = "^1.6" | ||
|
kdayday marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,49 @@ | ||
| using Documenter, HybridSystemsSimulations | ||
| import DataStructures: OrderedDict | ||
| using Documenter | ||
| using HybridSystemsSimulations | ||
| using DataStructures | ||
| using DocumenterInterLinks | ||
| using Literate | ||
|
|
||
| const _DOCS_BASE_URL = "https://nrel-sienna.github.io/HybridSystemsSimulations.jl/stable" | ||
|
|
||
| links = InterLinks( | ||
| "Julia" => "https://docs.julialang.org/en/v1/", | ||
| "InfrastructureSystems" => "https://nrel-sienna.github.io/InfrastructureSystems.jl/stable/", | ||
| "PowerSystems" => "https://nrel-sienna.github.io/PowerSystems.jl/stable/", | ||
| "PowerSimulations" => "https://nrel-sienna.github.io/PowerSimulations.jl/stable/", | ||
| ) | ||
|
|
||
| include(joinpath(@__DIR__, "make_tutorials.jl")) | ||
| make_tutorials() | ||
|
|
||
| pages = OrderedDict( | ||
| "Welcome Page" => "index.md", | ||
| "Quick Start Guide" => "quick_start_guide.md", | ||
| "Tutorials" => "tutorials/intro_page.md", | ||
| "Public API Reference" => "api/public.md", | ||
| "Internal API Reference" => "api/internal.md", | ||
| "Tutorials" => Any[], | ||
| "Reference" => Any[ | ||
| "Public API" => "api/public.md", | ||
| "Internals" => "api/internal.md", | ||
| ], | ||
| ) | ||
|
|
||
| makedocs( | ||
| modules=[HybridSystemsSimulations], | ||
| format=Documenter.HTML(; | ||
| mathengine=Documenter.MathJax(), | ||
| prettyurls=haskey(ENV, "GITHUB_ACTIONS"), | ||
| makedocs(; | ||
| modules = [HybridSystemsSimulations], | ||
| format = Documenter.HTML(; | ||
| mathengine = Documenter.MathJax(), | ||
| prettyurls = haskey(ENV, "GITHUB_ACTIONS"), | ||
| size_threshold = nothing, | ||
| ), | ||
| sitename="HybridSystemsSimulations.jl", | ||
| authors="Jose Daniel Lara, Rodrigo Henriquez-Auba", | ||
| pages=Any[p for p in pages], | ||
| sitename = "HybridSystemsSimulations.jl", | ||
| authors = "Jose Daniel Lara, Rodrigo Henriquez-Auba", | ||
| pages = Any[p for p in pages], | ||
| plugins = [links], | ||
| ) | ||
|
|
||
| deploydocs( | ||
| repo="github.com/NREL-Sienna/HybridSystemsSimulations.jl.git", | ||
| target="build", | ||
| branch="gh-pages", | ||
| devbranch="main", | ||
| devurl="dev", | ||
| push_preview=true, | ||
| versions=["stable" => "v^", "v#.#"], | ||
| deploydocs(; | ||
| repo = "github.com/NREL-Sienna/HybridSystemsSimulations.jl.git", | ||
| target = "build", | ||
| branch = "gh-pages", | ||
| devbranch = "main", | ||
| devurl = "dev", | ||
| push_preview = true, | ||
| versions = ["stable" => "v^", "v#.#"], | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.