Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
fbshipit-source-id: fff66bcac21896abcf52adf96c4a3dc1eae1b138
  • Loading branch information
facebook-github-bot committed Dec 11, 2021
0 parents commit 2e99c73
Show file tree
Hide file tree
Showing 653 changed files with 339,236 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: 2.1

commands:

user_install_beanmachine:
description: "Install beanmachine as an ordinary user would via pip"
steps:
- run:
name: "Install beanmachine"
command: pip install --progress-bar off -v .

pip_install_pytest_patch:
steps:
- run:
name: "Install a patched pytest version from PR (pytest-dev/pytest#7870)"
command: >
pip install --progress-bar off
git+https://github.com/pytest-dev/pytest.git@refs/pull/7870/head
apt_get_install_deps:
description: "Install beanmachine graph dependencies via apt-get"
steps:
- run:
name: "Update package lists"
command: sudo apt-get update
- run:
name: "Install Boost and Eigen"
command: sudo apt-get install libboost-dev libeigen3-dev

pip_list:
description: "Print out package info to help with debug"
steps:
- run:
name: "Pip list installed packages"
command: pip list

user_unit_tests:
description: "Run unit tests as an ordinary user"
steps:
- run:
name: "Install test dependencies"
command: pip install pytest
- run:
name: "Run unit tests"
no_output_timeout: 1h
command: pytest -vv

jobs:

user_install_test_py37_pip:
docker:
- image: circleci/python:3.7
steps:
- apt_get_install_deps
- checkout
- user_install_beanmachine
- pip_install_pytest_patch
- pip_list
- user_unit_tests

aliases:

- &exclude_ghpages_fbconfig
branches:
ignore:
- gh-pages
- fb-config


workflows:

lint_and_test:
jobs:
- user_install_test_py37_pip:
filters: *exclude_ghpages_fbconfig
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Issue Description
A clear and concise description of the issue. If it's a feature request, please add [Feature Request] to the title.

### Steps to Reproduce
Please provide steps to reproduce the issue attaching any error messages and stack traces.

### Expected Behavior
What did you expect to happen?

### System Info
Please provide information about your setup
- PyTorch Version (run `print(torch.__version__)`
- Python version

### Additional Context
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### Motivation
Please describe your motivation for the changes. Provide link to any related issues.

### Changes proposed
Outline the proposed changes and alternatives considered.

### Test Plan
Please provide clear instructions on how the changes were verified. Attach screenshots if applicable.

### Types of changes
- [ ] Docs change / refactoring / dependency upgrade
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

### Checklist
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **[CONTRIBUTING](https://github.com/facebookresearch/beanmachine/blob/main/CONTRIBUTING.md)** document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] The title of my pull request is a short description of the requested changes.
151 changes: 151 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Deployment

on:
# this workflow can only be manually triggered for now.
workflow_dispatch:
inputs:
deploy:
description: 'Where to deploy the artifacts? Only build, deploy to test PyPI, deploy to PyPI.'
required: true
type: choice
default: 'test'
options:
- build
- test
- prod

env:
PYTHONUNBUFFERED: 1

jobs:
build-wheel:
# do not run on forked repo
if: github.repository == 'facebookresearch/beanmachine'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: ['3.7', '3.8'] # TODO: Add python 3.10 with next PyTorch version
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 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: build_env

- name: Install dependencies
run: |
conda install -y eigen boost
python -m pip install --upgrade pip
pip install -U build
- name: Building Bean Machine wheel for ${{ matrix.os }}
run: python -m build --wheel

- name: Build Bean Machine source distribution
# source distribution only needs to be built on one OS
if: matrix.os == 'macos-latest'
run: python -m build --sdist

- name: Install built Bean Machine dist
run: pip install dist/*.whl

- name: Install pytest 7.0 (with a importlib patch in pytest-dev/pytest#7870)
run: pip install git+https://github.com/pytest-dev/pytest.git@7.0.0.dev0

- name: Print out package info to help with debug
run: pip list

- name: Run unit tests with pytest
run: pytest

- name: Sending wheels to the deployment workflow
uses: actions/upload-artifact@v2
with:
name: beanmachine-${{ matrix.os }}
path: dist/*

build-linux-wheel:
if: github.repository == 'facebookresearch/beanmachine'
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64
strategy:
matrix:
python-version: ['cp37-cp37m', 'cp38-cp38'] # TODO: Add python 3.10 with next PyTorch version

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install dependencies
run: |
yum install -y boost169-devel eigen3-devel
/opt/python/${{ matrix.python-version }}/bin/python -m pip install --upgrade pip
/opt/python/${{ matrix.python-version }}/bin/pip install -U build
- name: Building Bean Machine wheel for Linux
run: /opt/python/${{ matrix.python-version }}/bin/python -m build --wheel

- name: Repair wheel to support manylinux
run: auditwheel -v repair dist/*

- name: Install built Bean Machine dist
run: /opt/python/${{ matrix.python-version }}/bin/pip install wheelhouse/*.whl

- name: Install pytest 7.0 (with a importlib patch in pytest-dev/pytest#7870)
run: /opt/python/${{ matrix.python-version }}/bin/pip install git+https://github.com/pytest-dev/pytest.git@7.0.0.dev0

- name: Print out package info to help with debug
run: /opt/python/${{ matrix.python-version }}/bin/pip list

- name: Run unit tests with pytest
run: /opt/python/${{ matrix.python-version }}/bin/pytest

- name: Sending wheels to the deployment workflow
uses: actions/upload-artifact@v2
with:
name: beanmachine-manylinux
path: wheelhouse/*

publish-to-pypi:
runs-on: ubuntu-latest
needs:
- build-wheel
- build-linux-wheel
steps:
- name: Download wheels from previous jobs
# by default this will download all artifacts
uses: actions/download-artifact@v2

- name: Reorganize file structure
# PyPI publish action uploads everything under dist/*
run: |
ls -R
mkdir dist
mv beanmachine-*/* dist/
- name: Publish to Test PyPI
if: github.event.inputs.deploy == 'test'
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.TEST_PYPI_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
verbose: true

- name: Publish to PyPI
if: github.event.inputs.deploy == 'prod' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.PYPI_PASSWORD }}
verbose: true
75 changes: 75 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Documentation

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build_docs_job:
runs-on: ubuntu-latest
strategy:
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 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 dependencies
run: |
sudo apt-get install -y yarn
conda install -y eigen boost
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install notebook
- name: Install Bean Machine in editable mode
run: pip install -v -e .[dev]

# - name: Add tutorials to Docs
# run: |
# cd tutorials
# sh convert.sh
# cd ..

- name: Check env
run: echo `which sphinx-build`

- name: Build the docset
run: |
cd sphinx
pip install -r requirements.txt
make html
cd ..
- name: Build the Website
run: |
cd website
yarn install
yarn build
cd ..
- name: Get output time
run: echo "The time was ${{ steps.build.outputs.time }}"

- name: Deploy
if: ${{ github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: website/build # The folder the action should deploy.
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7]

steps:
- name: Checkout
uses: actions/checkout@v2

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

- name: Install linters
run: |
python -m pip install --upgrade pip
pip install black==20.8b1 usort flake8
- name: Print out package info to help with debug
run: pip list

- name: Lint with flake8
run: flake8 .

- name: Lint with usort
run: usort check .

- name: Lint with black
run: black --check .
Loading

0 comments on commit 2e99c73

Please sign in to comment.