Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
verbose-void committed May 1, 2021
0 parents commit e7f8b1f
Show file tree
Hide file tree
Showing 18 changed files with 1,237 additions and 0 deletions.
317 changes: 317 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
version: 2.1

orbs:
slack: circleci/slack@3.4.2
codecov: codecov/codecov@1.1.3
win: circleci/windows@2.4.0

workflows:
test:
jobs:
- test:
name: "Linux Simple Test"
e: linux
context:
- test
- azure
- test:
name: "Linux Complex Test"
e: linux
optional: true
context:
- test
- azure
- test:
name: "Mac Complex Test"
e: mac
mac-like: true
optional: true
context:
- test
- azure
test-and-deploy:
jobs:
- test:
name: test-simple
e: linux
context:
- test
- azure
filters: &version
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
- test:
name: test-complex
e: linux
optional: true
context:
- test
- azure
filters: *version
- verify:
type: approval
requires:
- test-simple
- test-complex
filters: *version
- deploy:
context:
- pypi
- snark-docker
requires:
- verify
filters: *version
- conda:
context:
- conda
requires:
- deploy
filters: *version

executors:
linux:
docker:
- image: circleci/python:3.8
win64: win/default
mac:
macos:
xcode: "12.4.0"

commands:
aliases:
steps:
- run:
name: "Setting aliases for Windows"
command: |
Add-Content -Path $profile -Value {Set-Alias -Name python3 -Value python}
Add-Content -Path $profile -Value {Set-Alias -Name pip3 -Value pip}
get-python:
steps:
- run:
name: "Install Python"
command: |
brew update
brew install python@3.7
brew link --overwrite python@3.7
info:
steps:
- run:
name: "Gather machine info"
command: python3 -c "import platform as p; print('{}\nPython {}'.format(p.platform(), p.sys.version))"

google-creds:
parameters:
unix-like:
type: boolean
default: true
steps:
- unless:
condition: << parameters.unix-like >>
steps:
- run:
name: "Prepare Google credentials - Windows"
command: |
$Env:CI_SECRETS_PATH = $Env:USERPROFILE + "\.secrets"
$Env:CI_GCS_PATH = $Env:CI_SECRETS_PATH + "\gcs.json"
setx /m CI_GCS_PATH "$Env:CI_GCS_PATH"
mkdir $Env:CI_SECRETS_PATH
[Text.Encoding]::ASCII.GetString([Convert]::FromBase64String($Env:GOOGLE_APPLICATION_CREDENTIALS)) | Out-File -FilePath $Env:CI_GCS_PATH -Encoding ASCII
- when:
condition: << parameters.unix-like >>
steps:
- run:
name: "Prepare Google credentials - Unix"
command: |
mkdir -p "$HOME/.secrets/"
echo "$GOOGLE_APPLICATION_CREDENTIALS" | base64 --decode > "$HOME/.secrets/gcs.json"
requirements:
parameters:
optional:
description: "Include optional requirements"
type: boolean
default: false
steps:
- run:
name: "Collecting requirements"
command: |
pip3 install --upgrade pip --user
pip3 install --upgrade setuptools
pip3 install -r requirements-dev.txt
<<# parameters.optional >>pip3 install -r requirements-optional.txt<</ parameters.optional >>
pip3 install -r requirements.txt
pip3 install -e .
style-check:
steps:
- run:
name: "Checking code style"
command: |
pip3 install flake8
flake8 . --count --exit-zero --max-complexity=10 --statistics
run-tests:
parameters:
unix-like:
type: boolean
default: true
steps:
- unless:
condition: << parameters.unix-like >>
steps:
- run:
name: "Running tests - Windows"
command: |
$Env:GOOGLE_APPLICATION_CREDENTIALS = $Env:CI_GCS_PATH
setx /m GOOGLE_APPLICATION_CREDENTIALS "$Env:GOOGLE_APPLICATION_CREDENTIALS"
pip3 install pytest
pip3 install pytest-cov
pytest --cov-report=xml --cov=./
- when:
condition: << parameters.unix-like >>
steps:
- run:
name: "Running tests - Unix"
command: |
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.secrets/gcs.json
pytest --cov-report=xml --cov=./
codecov-upload:
steps:
- codecov/upload:
file: coverage.xml
report:
parameters:
unix-like:
type: boolean
default: true
steps:
- unless:
condition: << parameters.unix-like >>
steps:
- run:
command: codecov-upload
shell: bash.exe
- when:
condition: << parameters.unix-like >>
steps:
- codecov-upload
- store_test_results:
path: test-reports # possibly change this path for Win
- store_artifacts:
path: test-reports
slack-status:
steps:
- slack/status:
fail_only: true
webhook: $SLACK_WEBHOOK
conda-install:
steps:
- run:
name: "Install Miniconda"
command: |
curl -O https://repo.anaconda.com/miniconda/Miniconda3-py38_4.9.2-Linux-x86_64.sh
echo "1314b90489f154602fd794accfc90446111514a5a72fe1f71ab83e07de9504a7 Miniconda3-py38_4.9.2-Linux-x86_64.sh" | sha256sum -c
bash Miniconda3-py38_4.9.2-Linux-x86_64.sh -b
echo 'export PATH=$HOME/miniconda3/bin:$PATH' >> $BASH_ENV
conda-setup:
steps:
- run:
name: "Install required conda packages and set config"
command: |
conda install conda-build anaconda-client patch -y
conda config --add channels conda-forge
conda config --set anaconda_upload yes
conda-build:
steps:
- run:
name: "Build Hub for conda"
command: |
pip install -e .
export HUB_VERSION=$(awk -F'=' '/^__version__/ { print $2}' $HOME/project/hub/version.py | tr -d ' "')
conda build .
jobs:
test:
parameters:
e:
type: executor
optional:
description: "Include optional requirements and reports"
type: boolean
default: false
unix-like:
type: boolean
default: true
mac-like:
type: boolean
default: false
executor: << parameters.e >>
steps:
- checkout
- unless:
condition: << parameters.unix-like >>
steps:
- aliases
- when:
condition: << parameters.mac-like >>
steps:
- get-python
- info
- google-creds:
unix-like: << parameters.unix-like >>
- requirements:
optional: << parameters.optional >>
- style-check
- run-tests:
unix-like: << parameters.unix-like >>
- when:
condition: << parameters.optional >>
steps:
- report:
unix-like: << parameters.unix-like >>
- slack-status
deploy:
executor: linux
environment:
IMAGE_NAME: snarkai/hub
steps:
- setup_remote_docker
- checkout
- run:
name: "Init .pypirc"
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = $TWINE_PASSWORD" >> ~/.pypirc
- run:
name: "Create a source distribution & wheel"
command: |
python3 setup.py sdist
python3 setup.py bdist_wheel
- run:
name: "Install twine via pip"
command: |
pip3 install twine
- run:
name: "Upload dist to PyPi"
command: |
twine upload --skip-existing dist/*
- run:
name: "Build Docker Hub Image"
command: |
docker build -t $IMAGE_NAME:latest .
- run:
name: "Deploy to Docker Hub"
command: |
echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
IMAGE_TAG=${CIRCLE_TAG}
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
docker push $IMAGE_NAME:latest
docker push $IMAGE_NAME:$IMAGE_TAG
- slack-status
conda:
executor: linux
steps:
- checkout
- conda-install
- conda-setup
- conda-build
- slack-status
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = */tests/*, hub/collections/*, hub/codec/*, setup.py
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
./dask-worker-space/
./cache
./data
./dist
./.pytest_cache
./hub.egg-info
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
extend-ignore = E203, W503
48 changes: 48 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''

---

## 🐛🐛 Bug Report


### ⚗️ Current Behavior
A clear and concise description of the behavior.

**Input Code**
- REPL or Repo link if applicable:

```python
def function_wrong():
pass
```

**Expected behavior/code**
A clear and concise description of what you expected to happen (or code).

```python
def function_right():
# Here is the fix
print("Ok)

```

### ⚙️ Environment

- `Python` version(s):
- *good*: [e.g. 3.8]
- **better**: [3.8.6 - Clang 12.0.0 (clang-1200.0.32.27)]
- `OS`: [e.g. Ubuntu 18.04, OSX 10.13.4, Windows 10]
- `IDE`: [Vim, VS-Code, Pycharme]
- `Packages`: [ `Tensorflow==2.1.2 - latest`]


### 🧰 Possible Solution (optional)
<!--- Only if you have suggestions on a fix for the bug -->

### 🖼 Additional context/Screenshots (optional)
Add any other context about the problem here. If applicable, add screenshots to help explain.
Loading

0 comments on commit e7f8b1f

Please sign in to comment.