From 733409dfce3cd9f768cf9d1c29c49f3f367ea4fd Mon Sep 17 00:00:00 2001 From: Winnie Zhang Date: Fri, 21 Oct 2022 14:48:54 -0700 Subject: [PATCH 1/2] Set Up Pyre Type Checking in Github Actions (#1751) Summary: Pull Request resolved: https://github.com/facebookresearch/beanmachine/pull/1751 Added in the .pyre_configuration.external file needed for configurator - Following the steps laid out in: https://www.internalfb.com/intern/staticdocs/pyre/docs/fb/open-source-setup/ Differential Revision: https://internalfb.com/D40400698 fbshipit-source-id: eef64061925528d08a88bf3fd122ea1904017c3f --- .github/workflows/lint.yml | 27 ++++++++++++++++++++++++--- .pyre_configuration | 12 ++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .pyre_configuration diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d4cd8474bd..110b54a8bc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,22 +13,31 @@ jobs: fail-fast: false matrix: python-version: [3.7] + defaults: + run: + # https://github.com/conda-incubator/setup-miniconda/tree/v2#use-a-default-shell + shell: bash -l {0} steps: - name: Checkout uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + - name: Set up Miniconda with Python ${{ matrix.python-version }} + uses: conda-incubator/setup-miniconda@v2 with: + auto-update-conda: true + miniconda-version: "latest" python-version: ${{ matrix.python-version }} + activate-environment: test_env - name: Install linters run: | python -m pip install --upgrade pip python -m pip install black==22.3.0 flake8==4.0.1 libcst==0.4.1 ufmt==1.3.2 usort==1.0.2 + VERSION=$(grep "version" .pyre_configuration | sed -n -e 's/.*\(0\.0\.[0-9]*\).*/\1/p') + pip install pyre-check-nightly==$VERSION - - name: Print out package info to help with debug + - name: Print out linter package info to help with debug run: pip list - name: Lint with flake8 @@ -36,3 +45,15 @@ jobs: - name: Lint with ufmt (black + usort) run: ufmt check . + + - name: Install dependencies (for Pyre) + run: | + conda install -c conda-forge -y boost-cpp eigen=3.4.0 + pip install torch --extra-index-url https://download.pytorch.org/whl/cpu + pip install -v -e .[dev] + + - name: Print out pyre package info to help with debug + run: pip list + + - name: Run Pyre + run: pyre diff --git a/.pyre_configuration b/.pyre_configuration new file mode 100644 index 0000000000..bc770b129a --- /dev/null +++ b/.pyre_configuration @@ -0,0 +1,12 @@ +{ + "site_package_search_strategy": "all", + "search_path": [ + { + "site-package": "beanmachine" + } + ], + "source_directories": [ + "./src/beanmachine/ppl" + ], + "version": "0.0.101665573068" +} From 8faf3c28c544dfdb3924bc5e3041e51564024fd8 Mon Sep 17 00:00:00 2001 From: Steven Troxler Date: Fri, 21 Oct 2022 14:49:22 -0700 Subject: [PATCH 2/2] Try using `src` as the source directory Summary: This may lead to more code being type checked than desired, but I think we can use excludes to handle this if that is a problem. Differential Revision: D40606047 fbshipit-source-id: 02a37c5b3a792a2202f5e91c8460bb5c2f68b51d --- .pyre_configuration | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pyre_configuration b/.pyre_configuration index bc770b129a..9f4fcd0063 100644 --- a/.pyre_configuration +++ b/.pyre_configuration @@ -6,7 +6,7 @@ } ], "source_directories": [ - "./src/beanmachine/ppl" + "./src" ], "version": "0.0.101665573068" }