From 5239b3555339b62b9f8040a8fd43d9231e76c4e2 Mon Sep 17 00:00:00 2001 From: gitaroktato Date: Tue, 9 Apr 2024 17:16:38 +0200 Subject: [PATCH 1/5] feat: Adding mypy checks --- .github/workflows/python-app.yml | 20 +++++++++++++++++++- README.md | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index e8bdc6e..e05cf95 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python 3.12 uses: actions/setup-python@v3 with: python-version: "3.12" @@ -37,3 +37,21 @@ jobs: - name: Test with pytest run: | pytest + + mypy: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.12" + - name: Checkout + uses: actions/checkout@v1 + - name: Install mypy + run: pip install mypy + - name: Run mypy + uses: sasanquaneuf/mypy-github-action@releases/v1 + with: + checkName: 'mypy' # NOTE: this needs to be the same as the job name + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 7b56303..44b9591 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ jupyter lab - https://github.com/miguelrizzog96/Queue_Simulation_Python/blob/master/server.ipynb - https://notebook.community/xunilrj/sandbox/courses/IMTx-Queue-Theory/Week2_Lab_MM1 - https://github.com/eveneveno/MMC_queue +- https://github.com/miguelrizzog96/Queue_Simulation_Python ## Distributions - https://numpy.org/doc/stable/reference/random/generated/numpy.random.exponential.html From c32274eb95f2092b79571c609c1d396eb1f944f6 Mon Sep 17 00:00:00 2001 From: gitaroktato Date: Tue, 9 Apr 2024 17:21:59 +0200 Subject: [PATCH 2/5] fix: Adding dependencies for mypy --- .github/workflows/python-app.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index e05cf95..7d38b2c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -48,7 +48,10 @@ jobs: - name: Checkout uses: actions/checkout@v1 - name: Install mypy - run: pip install mypy + run: | + python -m pip install --upgrade pip + pip install mypy + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Run mypy uses: sasanquaneuf/mypy-github-action@releases/v1 with: From 95a7ecbca933f58b62580774b4c1179c5805115c Mon Sep 17 00:00:00 2001 From: gitaroktato Date: Tue, 9 Apr 2024 17:27:42 +0200 Subject: [PATCH 3/5] fix: Fixing mypy issues --- src/queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/queue.py b/src/queue.py index 271a7fe..54bd249 100644 --- a/src/queue.py +++ b/src/queue.py @@ -7,7 +7,7 @@ def __init__(self, inter_arrival_times, execution_times, executors=1) -> None: self.__execution_times = execution_times self.__departure_times = np.empty_like(inter_arrival_times) self.__wait_times = np.empty_like(inter_arrival_times) - self.__utilization_by_executor = { + self.__utilization_by_executor: dict[int, list[float]] = { executor_id: [] for executor_id in range(0, executors) } From 61fe0cb39f2ca5de7e4f823e50f1a294de17d4e0 Mon Sep 17 00:00:00 2001 From: gitaroktato Date: Tue, 9 Apr 2024 17:29:26 +0200 Subject: [PATCH 4/5] fix: Adding python package caching --- .github/workflows/python-app.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 7d38b2c..a579a0a 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -23,6 +23,7 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.12" + cache: 'pip' # caching pip dependencies - name: Install dependencies run: | python -m pip install --upgrade pip @@ -45,6 +46,7 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.12" + cache: 'pip' # caching pip dependencies - name: Checkout uses: actions/checkout@v1 - name: Install mypy From 544b2e615d46e635f8d3405fa9b6f363041a2b66 Mon Sep 17 00:00:00 2001 From: gitaroktato Date: Tue, 9 Apr 2024 17:33:05 +0200 Subject: [PATCH 5/5] fix: Using single job --- .github/workflows/python-app.yml | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index a579a0a..2630c41 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest + pip install flake8 pytest mypy if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | @@ -35,28 +35,12 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Run mypy + uses: sasanquaneuf/mypy-github-action@releases/v1 + with: + checkName: 'build' # NOTE: this needs to be the same as the job name + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test with pytest run: | pytest - - mypy: - runs-on: ubuntu-latest - steps: - - name: Setup Python - uses: actions/setup-python@v3 - with: - python-version: "3.12" - cache: 'pip' # caching pip dependencies - - name: Checkout - uses: actions/checkout@v1 - - name: Install mypy - run: | - python -m pip install --upgrade pip - pip install mypy - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Run mypy - uses: sasanquaneuf/mypy-github-action@releases/v1 - with: - checkName: 'mypy' # NOTE: this needs to be the same as the job name - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}