From e4ef183b2c3e15b2ed216eb2a5e50114168ca882 Mon Sep 17 00:00:00 2001 From: Radhakrishna Sanka Date: Mon, 23 Oct 2023 14:59:34 +0530 Subject: [PATCH] Dev (#21) * Fixed issue where the layers writer does not have a new line input. * Fixed issue where there were no newlines between multiple layers * * Added the pytest plugin for poetry run * Updated the create valve code to use the mintdevice method instead of using parchmint api * Autoformatted `mintcompler.py` code * style: format code with Black and isort This commit fixes the style issues introduced in 27ec437 according to the output from Black and isort. Details: https://github.com/CIDARLAB/pyMINT/pull/21 * Updated the test CI * Updated actions to include graphviz install * Added sudo for it to install --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 29 +++++++++++++++++------------ pymint/mintcompiler.py | 18 +++++++++++------- pyproject.toml | 6 ++++++ 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dd658b..91d2e1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,23 +16,28 @@ jobs: use-isort: true test: - runs-on: ubuntu-latest - + strategy: + fail-fast: false + matrix: + python-version: [3.8] + poetry-version: [1.3.1] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} steps: + - name: Install graphviz deps + run: sudo apt-get install -y graphviz-dev - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 + - uses: actions/setup-python@v2 with: - python-version: 3.8 - - name: Install Poetry - uses: snok/install-poetry@v1 + python-version: ${{ matrix.python-version }} + - name: Run image + uses: abatilo/actions-poetry@v2.0.0 with: - version: 1.1.1 - virtualenvs-create: false - - name: Install Dependencies + poetry-version: ${{ matrix.poetry-version }} + - name: Install dependencies run: poetry install - - name: Running pytest - run: poetry run pytest + - name: Run tests + run: poetry run pytest docs: needs: [test] diff --git a/pymint/mintcompiler.py b/pymint/mintcompiler.py index f6cf143..ee4272c 100644 --- a/pymint/mintcompiler.py +++ b/pymint/mintcompiler.py @@ -2,6 +2,7 @@ from typing import Dict, Optional from parchmint import Layer, Target +from parchmint.device import ValveType from pymint.antlrgen.mintListener import mintListener from pymint.antlrgen.mintParser import mintParser @@ -384,12 +385,8 @@ def exitValveStat(self, ctx: mintParser.ValveStatContext): valve_name = ctx.ufname()[0].getText() # type: ignore if not (self._current_layer is not None and self._current_layer.ID is not None): raise AssertionError - valve_component = self.current_device.create_mint_component( - valve_name, - entity, - self.current_params, - [self._current_layer.ID], - ) + + # Get the connection information connection_name = ctx.ufname()[1].getText() # type: ignore valve_connection = self.current_device.device.get_connection(connection_name) if valve_connection is None: @@ -399,7 +396,14 @@ def exitValveStat(self, ctx: mintParser.ValveStatContext): ) ) - self.current_device.device.map_valve(valve_component, valve_connection) + self.current_device.create_valve( + name=valve_name, + technology=entity, + params=self.current_params, + layer_ids=[self._current_layer.ID], + connection=valve_connection, + valve_type=ValveType.NORMALLY_OPEN, + ) def enterViaStat(self, ctx: mintParser.ViaStatContext): if self.current_device is None: diff --git a/pyproject.toml b/pyproject.toml index 8b91b0c..c782d34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,3 +43,9 @@ docs = ["sphinx"] [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" + +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = [ + "./tests/" +] \ No newline at end of file