Skip to content

Commit

Permalink
Add Level 1 5G DES system (#539)
Browse files Browse the repository at this point in the history
* update dependency versions

* initial files added for creating 5g system from existing load files

* fix path type, ignore for now

* fix types on methods, bump to python 3.8 (#540)

* fix types on methods, bump to python 3.8

* update ci exclude

* add in directory to the mos copying

* systemparameter needs to use the same data... favor param_template over data.

* expose nBui to set correctly

* default to openmodelica and fix space check in file name
  • Loading branch information
nllong committed Apr 28, 2023
1 parent d99d306 commit 071da23
Show file tree
Hide file tree
Showing 23 changed files with 27,242 additions and 156 deletions.
47 changes: 23 additions & 24 deletions .github/workflows/ci.yml
Expand Up @@ -22,34 +22,33 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.11"]
test_env: [python, docs]
python-version: ["3.9", "3.11"]
test_env: [python, docs, mypy]
mbl_branch: [maint_9.1.x]
include:
- os: ubuntu-latest
test_env: python
mbl_branch: maint_9.1.x
exclude:
# only test mypy on linux for all versions of python
- os: windows-latest
test_env: mypy
# only test docs on linux for all versions of python
- os: windows-latest
test_env: docs
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
-
name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
-
name: Display system info
- name: Display system info
run: |
python -c "import sys; print(sys.version)"
docker --version
docker-compose --version
-
name: Install and configure Poetry
- name: Install and configure Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.3.1
-
name: Install dependencies with Poetry
- name: Install dependencies with Poetry
run: |
poetry --version
poetry install
Expand All @@ -62,8 +61,7 @@ jobs:
# mkdir -p /home/runner/modelon
# echo "#Please do not delete this comment line." > /home/runner/modelon/license.lic
# echo "${{ secrets.MODELON_LICENSE_FILE }}" >> /home/runner/modelon/license.lic
-
name: Install modelicafmt
- name: Install modelicafmt
run: |
RUNNER_SYSTEM=$(python -c 'import platform; print(platform.system())')
curl -SLO "https://github.com/urbanopt/modelica-fmt/releases/download/v0.2-pr.2/modelica-fmt_0.2-pr.2_${RUNNER_SYSTEM}_x86_64.tar.gz"
Expand All @@ -74,8 +72,7 @@ jobs:
else
mv modelicafmt '/c/Program Files/'
fi
-
name: Install MBL
- name: Install MBL
env:
MATRIX_OS: ${{ matrix.os }}
MBL_BRANCH: ${{ matrix.mbl_branch }}
Expand All @@ -99,8 +96,7 @@ jobs:
# run: |
# cd geojson_modelica_translator/modelica/lib/runner
# docker-compose build
-
name: Run PyTest
- name: Run pytest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
# MODELON_MAC_ADDRESS: ${{ secrets.MODELON_MAC_ADDRESS }}
Expand All @@ -113,22 +109,25 @@ jobs:
uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files
- name: Run mypy
run: |
if [ '${{ matrix.test_env }}' == 'mypy' ]; then
poetry run mypy --install-types --non-interactive --show-error-codes .
fi
- name: Build docs
run: |
if [ '${{ matrix.test_env }}' == 'docs' ]; then
cd docs
poetry run make html
fi
-
name: Coveralls
- name: Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' && matrix.mbl_branch == 'maint_9.1.x' }}
run: |
poetry run coveralls
-
name: Job Failed
- name: Job Failed
if: ${{ failure() }}
run: |
echo "Maybe these logs will help?"
Expand Down
2 changes: 1 addition & 1 deletion geojson_modelica_translator/geojson/schemas.py
Expand Up @@ -4,7 +4,7 @@
import json
import os

from jsonschema.validators import _LATEST_VERSION as LatestValidator
from jsonschema.validators import Draft202012Validator as LatestValidator


class Schemas(object):
Expand Down
7 changes: 5 additions & 2 deletions geojson_modelica_translator/model_connectors/model_base.py
Expand Up @@ -4,6 +4,7 @@
import logging
import shutil
from pathlib import Path
from typing import Union

from jinja2 import Environment, FileSystemLoader, StrictUndefined, exceptions
from modelica_builder.model import Model
Expand All @@ -24,7 +25,7 @@ class ModelBase(object):
feature) to a detailed Modelica connection. For example, a simple RC model (using TEASER), a ROM, CSV file, etc.
"""
# model_name must be overridden in subclass
model_name = None
model_name: Union[str, None] = None

def __init__(self, system_parameters, template_dir):
"""
Expand Down Expand Up @@ -114,7 +115,9 @@ def run_template(self, template, save_file_name, do_not_add_to_list=False, **kwa
"""
file_data = template.render(**kwargs)

Path(save_file_name).parent.mkdir(parents=True, exist_ok=True)
if not isinstance(save_file_name, Path):
save_file_name = Path(save_file_name)
save_file_name.parent.mkdir(parents=True, exist_ok=True)
with open(save_file_name, "w") as f:
f.write(file_data)

Expand Down

0 comments on commit 071da23

Please sign in to comment.