This repository contains the Data Transfer Objects (DTO) used to standardise the model developments in U2Demo. These DTOs are organised by algorithm, as outlined in Deliverable D4.1, with one file per algorithm, found in u2demo_clearing_engine/dto. These algorithms also share some commonalities, which are stored in the commons files under u2demo_clearing_engine/dto/algorithm_libraries. In each DTO, the attributes are specified using Pydantic syntax, with eventually some attribute constraints included in the attribute definition. For example, for a positive attribute, the constraint attribute >= 0 is included in the attribute definition. Object Oriented Programming principles are followed as much as possible, with inheritence between classes whenever relevant, in order to structure the DTO definitions.
- The source code containing the DTOs for each algorithm and the common algorithms is contained in u2demo_clearing_engine/dto.
- The json files containing all class descriptions following the OpenAPI Specification are contained in u2demo_clearing_engine/openapi (see instruction in "Generating docs" to generate these documents yourself).
- The corresponding html files are contained in the same openapi folder.
- The mermaid files and the corresponding svg files outline the inheritance between classes and provide a visual representation of the attributes contained in each class (see instruction in "Generating docs" to generate these documents yourself).
Steps to follow:
- Run python -m u2demo_clearing_engine.app. This launches the local server. The API description is found on http://localhost:8000/docs
- Run the shell commands below (install @redocly/cli if necessary, as commented below). This generates the json and corresponding html files.
# npm install -g @redocly/cli
curl http://localhost:8000/openapi.json > doc/openapi/u2demo_optimization_api.json
redocly build-docs doc/openapi/u2demo_optimization_api.json -o doc/openapi/u2demo-optimization-doc.html
-
Run python -m doc.mermaid_charts.create_mmd to create the mermaid files
-
Run the shell command below to convert the mermaid file into svgs (install mermaid-cli if necessary).
# npm install -g @mermaid-js/mermaid-cli
#!/bin/bash
# Define your list of base names
names=('centralized_dispatch_cems_dto' 'centralized_dispatch_p2p_dto' 'centralized_dispatch_benefit_allocation_dto' 'market_clearing_dto' 'pricing_model_dto' 'individual_portfolio_optimisation_dto')
# Loop through each name and generate the SVG
for n in "${names[@]}"; do
mmdc -i "doc/mermaid_charts/${n}.md" -o "doc/mermaid_charts/${n}.svg"
done