Skip to content
Open
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
74 changes: 40 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
fail_fast: true
repos:
- repo: local
hooks:
- repo: local
hooks:
- id: pyink
name: pyink
entry: poetry run pyink
language: system
types: [file, python]
files: "^smart_control/"
exclude: "^smart_control/Dockerfile"

- id: pyink
name: pyink
entry: poetry run pyink
language: system
types: [file, python]
files: '^smart_control/'
exclude: '^smart_control/Dockerfile'
- id: isort
name: isort
entry: poetry run isort
language: system
types: [file, python]
files: "^smart_control/"
exclude: "^smart_control/proto/"

- id: isort
name: isort
entry: poetry run isort
language: system
types: [file, python]
files: '^smart_control/'
exclude: '^smart_control/proto/'
# NOTE: running `pylint` against all files is prohibitively slow
# ... so we omit passing the `smart_buildings` directory,
# ... which allows pre-commit to run against staged / changed files only
- id: pylint
name: pylint
#entry: pylint --rcfile=.pylintrc --ignore=proto smart_control
#entry: pylint --rcfile=.pylintrc --ignore=proto $(git diff --name-only --staged | grep -E '\.py$')
entry: pylint --rcfile=.pylintrc --ignore=proto
language: system
types: [file, python]
files: "^smart_control/"
exclude: "^smart_control/proto/"

# NOTE: running `pylint` against all files is prohibitively slow
# ... so we omit passing the `smart_buildings` directory,
# ... which allows pre-commit to run against staged / changed files only
- id: pylint
name: pylint
#entry: pylint --rcfile=.pylintrc --ignore=proto smart_control
#entry: pylint --rcfile=.pylintrc --ignore=proto $(git diff --name-only --staged | grep -E '\.py$')
entry: pylint --rcfile=.pylintrc --ignore=proto
language: system
types: [file, python]
files: '^smart_control/'
exclude: '^smart_control/proto/'
- id: uml-generator
name: Generate UML Diagram
entry: make uml
language: system
files: ^smart_control/.*\.py$
stages: [commit]

# See: https://mdformat.readthedocs.io/en/stable/users/installation_and_usage.html#usage-as-a-pre-commit-hook
- repo: https://github.com/hukkin/mdformat
rev: 0.7.22
hooks:
- id: mdformat
exclude: ^docs/api/
# See: https://mdformat.readthedocs.io/en/stable/users/installation_and_usage.html#usage-as-a-pre-commit-hook
- repo: https://github.com/hukkin/mdformat
rev: 0.7.22
hooks:
- id: mdformat
exclude: ^docs/api/
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ docs-quiet:

docs-build:
poetry run mkdocs build

#
# UML Diagram
#
uml:
@echo "--- Generating UML class diagram ---"
pyreverse -o dot -p smart_control smart_control/
dot -Tpng classes_smart_control.dot -o docs/images/class_diagram.png
rm classes_smart_control.dot packages_smart_control.dot
238 changes: 238 additions & 0 deletions classes_smart_control.dot

Large diffs are not rendered by default.

Binary file added docs/images/class_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ efficiency, operational costs, and occupant comfort.

This project is an open source collaboration between Google and partner
organizations in academia and industry.

## Code Architecture

To help understand the connections between classes, the following UML class diagram is automatically generated from the source code.

![UML Class Diagram](images/class_diagram.png)
1 change: 1 addition & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project requires the following system dependencies:
- [Protocol Buffer Compiler](https://grpc.io/docs/protoc-installation/)
(`v 3.21.12`)
- [FFmpeg](https://ffmpeg.org/) (`v 7.1.1`)
- [Graphviz](https://graphviz.org/download/) (for generating documentation diagrams)
- Python (`>=3.10.12 and <3.12`)

## Repository Setup
Expand Down
648 changes: 648 additions & 0 deletions packages_smart_control.dot

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions smart_control/simulator/stochastic_occupancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ def __init__(
random_state: np.random.RandomState,
time_zone: Union[datetime.tzinfo, str] = "UTC",
):
assert (
# Validate that the time bounds are in chronological order
if not (
earliest_expected_arrival_hour
< latest_expected_arrival_hour
< earliest_expected_departure_hour
< latest_expected_departure_hour
)
assert lunch_start_hour < lunch_end_hour
):
raise ValueError(
"Time bounds must be in chronological order i.e., "
"expected arrival/departure hours must be strictly increasing:" "earliest_expected_arrival_hour < latest_expected_arrival_hour "
"< earliest_expected_departure_hour < latest_expected_departure_hour."
)

# Validate lunch time bounds
if lunch_start_hour >= lunch_end_hour:
raise ValueError("lunch_start_hour must be before lunch_end_hour.")

self._earliest_expected_arrival_hour = earliest_expected_arrival_hour
self._latest_expected_arrival_hour = latest_expected_arrival_hour
Expand Down
Loading