From 93033f1bce6035cfa41bb9963f26749236fd5018 Mon Sep 17 00:00:00 2001 From: swotai Date: Tue, 12 Mar 2024 21:09:24 -0700 Subject: [PATCH] Black lint fix 20230311 (#859) Fix black linting, add dependency to have unit test run after lint --- .github/workflows/black.yaml | 33 +++------------------ .github/workflows/pypi-deploy.yaml | 2 +- .github/workflows/{build.yaml => test.yaml} | 19 +++++++----- .gitignore | 1 + orbit/utils/stan.py | 12 ++++---- 5 files changed, 24 insertions(+), 43 deletions(-) rename .github/workflows/{build.yaml => test.yaml} (69%) diff --git a/.github/workflows/black.yaml b/.github/workflows/black.yaml index 58f420e7..26b1a8af 100644 --- a/.github/workflows/black.yaml +++ b/.github/workflows/black.yaml @@ -6,33 +6,8 @@ jobs: lint: runs-on: ubuntu-latest steps: - # - uses: actions/checkout@v3 - # - uses: psf/black@stable - # Currently only checking instead of auto formatting - # - uses: jpetrucciani/black-check@master - # - name: Install Dependencies - # run: | - # python -m pip install --upgrade pip - # pip install -r requirements-test.txt - # pip install black --upgrade - # - name: black check diff - # run: black --diff . - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - uses: psf/black@stable with: - python-version: 3.9 # Set to your preferred Python version - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-test.txt - pip install black --upgrade - - # - name: Run Black Check - # run: black --check . # conforms Black's style without changing it - - - name: Show Black Diff - run: black --diff . # shows the diff of Black changes, if any \ No newline at end of file + options: "--check --verbose --color" + jupyter: true diff --git a/.github/workflows/pypi-deploy.yaml b/.github/workflows/pypi-deploy.yaml index a89c439c..62d9bc71 100644 --- a/.github/workflows/pypi-deploy.yaml +++ b/.github/workflows/pypi-deploy.yaml @@ -3,7 +3,7 @@ # separate terms of service, privacy policy, and support # documentation. -name: Deploy package to PyPI +name: Deploy Package to PyPI on: release: diff --git a/.github/workflows/build.yaml b/.github/workflows/test.yaml similarity index 69% rename from .github/workflows/build.yaml rename to .github/workflows/test.yaml index 73b66d33..9ee2130a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/test.yaml @@ -1,9 +1,12 @@ -name: build +name: Build and Test -on: [push] +on: + workflow_run: + workflows: [Lint] + types: [completed] jobs: - build: + on_success: # [macos-latest, macos-latest, windows-latest] runs-on: ubuntu-latest strategy: @@ -23,9 +26,9 @@ jobs: run: python -c "import sys; print(sys.version)" - name: Install dependencies run: | - pip install -U pip - pip install -U setuptools - pip install -r requirements.txt - python -m pip install -U --editable ".[dev]" + pip install -U pip + pip install -U setuptools + pip install -r requirements.txt + python -m pip install -U --editable ".[dev]" - name: Test with pytest - run: python -m pytest tests/ + run: python -m pytest tests/ diff --git a/.gitignore b/.gitignore index d210c62c..e2cbf0c4 100644 --- a/.gitignore +++ b/.gitignore @@ -105,6 +105,7 @@ tutorial/_build/ !.jenkins/ !.scaffold.yaml !.readthedocs.yml +!.github/ # Java *.class diff --git a/orbit/utils/stan.py b/orbit/utils/stan.py index 773e620e..4f8441c3 100644 --- a/orbit/utils/stan.py +++ b/orbit/utils/stan.py @@ -31,7 +31,7 @@ def get_compiled_stan_model( - stan_model_name: str = "", + stan_model_name: str = "", stan_file_path: Optional[str] = None, exe_file_path: Optional[str] = None, force_compile: bool = False, @@ -43,12 +43,12 @@ def get_compiled_stan_model( ---------- stan_model_name : The name of the Stan model to use. Use this for the built in models (dlt, ets, ktrlite, lgt) - stan_file_path : + stan_file_path : The path to the Stan file to use. If not provided, the default is to search for the file in the 'orbit' package. If provided, function will ignore the stan_model_name parameter, and will compile the provide stan_file_path into executable in place (same folder as stan_file_path) - exe_file_path : - The path to the Stan-exe file to use. If not provided, the default is to search for the file + exe_file_path : + The path to the Stan-exe file to use. If not provided, the default is to search for the file in the 'orbit' package. If provided, function will ignore the stan_model_name parameter, and will compile the provide stan_file_path into executable in place (same folder as stan_file_path) Returns @@ -57,7 +57,9 @@ def get_compiled_stan_model( A compiled Stan model. """ if (stan_file_path is not None) or (exe_file_path is not None): - sm = CmdStanModel(stan_file=stan_file, exe_file=exe_file_path, force_compile=force_compile) + sm = CmdStanModel( + stan_file=stan_file, exe_file=exe_file_path, force_compile=force_compile + ) else: # Load orbit included cmdstan models # Some oddities here. if not providing exe_file, CmdStanModel would delete the actual executable file.