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

3 update build system for all packages #9

Merged
merged 9 commits into from
Mar 27, 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
49 changes: 49 additions & 0 deletions .github/workflows/publish_MachSysS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Python 🐍 distribution 📦 to PyPI for FEEMS

on:
push:
branches: ["main"]

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build --user
- name: Build package
run: |
cd machinery-system-structure
python -m build
- name: Store the distribution packages 📦
uses: actions/upload-artifact@v3
with:
name: python-package-distributions-MachSysS
path: machinery-system-structure/dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/MachSysS
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: python-package-distributions-MachSysS
path: machinery-system-structure/dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
49 changes: 49 additions & 0 deletions .github/workflows/publish_RunFeemsSim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Python 🐍 distribution 📦 to PyPI for FEEMS

on:
push:
branches: ["main"]

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build --user
- name: Build package
run: |
cd RunFEEMSSim
python -m build
- name: Store the distribution packages 📦
uses: actions/upload-artifact@v3
with:
name: python-package-distributions-RunFeemsSim
path: RunFEEMSSim/dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/RunFeemsSim
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: python-package-distributions-RunFeemsSim
path: RunFEEMSSim/dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
49 changes: 49 additions & 0 deletions .github/workflows/publish_feems.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Python 🐍 distribution 📦 to PyPI for FEEMS

on:
push:
branches: ["main"]

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry --user
- name: Build package
run: |
cd feems
poetry build
- name: Store the distribution packages 📦
uses: actions/upload-artifact@v3
with:
name: python-package-distributions-feems
path: feems/dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/feems
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: python-package-distributions-feems
path: feems/dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: ["*"]
pull_request:
branches: ["*"]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
project:
- feems
- machinery-system-structure
- RunFEEMSSim

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip setuptools
pip install -r requirements_dev.txt

- name: Test with pytest if the project is feems else test with nbdev
run: |
cd ${{ matrix.project }}
if [ "${{ matrix.project }}" = "feems" ]; then
pytest
else
nbdev_test --do_print
fi
127 changes: 63 additions & 64 deletions RunFEEMSSim/00_machinery_calculation.ipynb

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions RunFEEMSSim/01_pms_basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"metadata": {},
"outputs": [],
"source": [
"#| default_exp pms_basic"
"# | default_exp pms_basic"
]
},
{
Expand All @@ -28,7 +28,7 @@
"metadata": {},
"outputs": [],
"source": [
"#| include: false\n",
"# | include: false\n",
"from nbdev.showdoc import *"
]
},
Expand All @@ -38,7 +38,7 @@
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"# | export\n",
"import itertools\n",
"from dataclasses import dataclass\n",
"from itertools import chain\n",
Expand Down Expand Up @@ -130,17 +130,14 @@
" electric_system = (\n",
" system if not hasattr(system, \"electric_system\") else system.electric_system\n",
" )\n",
" power_sources = [\n",
" component\n",
" for component in electric_system.power_sources\n",
" ]\n",
" power_sources = [component for component in electric_system.power_sources]\n",
" if component_types is not None:\n",
" power_sources = [\n",
" component for component in power_sources if component.type in component_types\n",
" component\n",
" for component in power_sources\n",
" if component.type in component_types\n",
" ]\n",
" rated_power_all = [\n",
" power_source.rated_power for power_source in power_sources\n",
" ]\n",
" rated_power_all = [power_source.rated_power for power_source in power_sources]\n",
" return min_load_table_dict(\n",
" rated_power_all, maximum_allowed_genset_load_percentage / 100\n",
" )\n",
Expand Down Expand Up @@ -200,7 +197,11 @@
" n_datapoint_max = max(n_datapoints)\n",
" if len(n_datapoints) > 1:\n",
" for swb_id, power_kw in power_kw_per_switchboard.items():\n",
" if len(power_kw) < n_datapoint_max and len(power_kw) != 1 and power_kw[0] != 0:\n",
" if (\n",
" len(power_kw) < n_datapoint_max\n",
" and len(power_kw) != 1\n",
" and power_kw[0] != 0\n",
" ):\n",
" raise ValueError(\n",
" f\"Load vector for switchboard {swb_id} has length {len(power_kw)} \"\n",
" f\"but should have length {n_datapoint_max} or 1 with 0 value.\"\n",
Expand Down
2 changes: 1 addition & 1 deletion RunFEEMSSim/RunFeemsSim/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.1a"
__version__ = "0.2.2"
Loading
Loading