Skip to content

Commit

Permalink
Feature/update-repo-setup (#74)
Browse files Browse the repository at this point in the history
..
  • Loading branch information
dongminlee94 committed Jun 12, 2022
1 parent 8e95eef commit 77fab64
Show file tree
Hide file tree
Showing 72 changed files with 4,422 additions and 193 deletions.
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
max-line-length = 104
max-complexity = 18
select = B,C,E,F,W,T4,B9
extend-ignore = E203, W503
ignore = E203, E226, E266, E501, W503, E265
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Bug report
name: Bug issue template
about: Create a report to help us improve
title: ''
labels: ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Feature request
name: Feature request template
about: Suggest an idea for this project
title: ''
labels: ''
Expand Down
18 changes: 18 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 1
labels:
- label: "WIP"
title: "^WIP:.*"
- label: "feature"
branch: "^feature/.*"
- label: "bugfix"
branch: "^bugfix/.*"
- label: "enh"
branch: "^enhance/.*"
- label: "style"
branch: "^style/*"
- label: "docs"
branch: "^docs/*"
- label: "release"
branch: "^release/v[0-9]+[.][0-9]+[.][0-9]+"
- label: "need-to-change-branch-name"
branch: "^(?!^feature/.*$)(?!^bugfix/.*$)(?!^enhance/.*$)(?!^style/.*$)(?!^docs/.*$).*$"
16 changes: 6 additions & 10 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

[//]: # (Please explain the changes you made.)

## Related Issues
## Test

[//]: # (Please link the related issues, if applicable.)
[//]: # (Please explain how to test the code.)

## Checklist
## Related Issues

- [ ] **Assignees** ran the [make format](https://github.com/dongminlee94/meta-rl#development).
- [ ] **Assignees** ran the [make lint](https://github.com/dongminlee94/meta-rl#development) command and the code passed the linters.
- [ ] **Assignees** updated the README, if necessary.
- [ ] **Assignees** checked the runnability of the code.
- [ ] **Reviewers** checked the runnability of the code.
[//]: # (Please link the related issues, if applicable.)

## Optional section (e.g., code usage, experimental results, TODO)
## Anything Else? (Optional) Optional section (e.g., code usage, experimental results, TODO)

[//]: # (If Assignees have any additional information, please add them.)
[//]: # (If there are any other things (e.g., code usage, experimental results, TODO), please explain them.)
43 changes: 43 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Automation] Pull Request"
on:
pull_request:
types: [opened, synchronize, edited, reopened, closed]

jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: anencore94/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

assign-reviewer:
runs-on: ubuntu-latest
steps:
- name: reviewers
uses: hkusu/review-assign-action@v1
with:
assignees: ${{ github.actor }}
reviewers: dongminlee94, Clyde21c
max-num-of-reviewers: 2
draft-keyword: WIP # A keyword in the pull request title to treat as draft pull requests

size-label:
runs-on: ubuntu-latest
steps:
- name: size-label
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IGNORED: "**/component.yaml\n**/__init__.py"
with:
sizes: >
{
"0": "XS",
"8": "S",
"40": "M",
"110": "L",
"400": "XL",
"1000": "XXL",
"3000": "XXXL"
}
33 changes: 33 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Repo CI] Python Code"

on:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8.8
- name: Initial setup
shell: bash -l {0}
run: make init-dev
- uses: pre-commit/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

check-build-package:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.8.8
- name: Build python package
run: |
pip install wheel
python setup.py sdist bdist_wheel --universal
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ venv.bak/
runs/

# results
results/
results/
42 changes: 30 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: format
name: format
language: system
entry: make format
types: [python]
- id: lint
name: lint
language: system
entry: make lint
types: [python]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
- id: check-added-large-files
args: ["--maxkb=30000"]
- id: requirements-txt-fixer

- repo: local
hooks:
- id: format
name: format
language: system
entry: make format

- repo: local
hooks:
- id: lint
name: lint
language: system
entry: make lint

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.0.1
hooks:
- id: add-trailing-comma
6 changes: 5 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ disable=print-statement,
no-name-in-module,
import-error,
duplicate-code,
too-many-instance-attributes,
too-many-arguments,
too-many-locals,
not-callable,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -591,4 +595,4 @@ min-public-methods=2
# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception
Exception
2 changes: 1 addition & 1 deletion LICENSE.md → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Dongmin Lee
Copyright (c) 2022 Dongmin Lee

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
49 changes: 41 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
GPU := $(shell which nvcc)
ifdef GPU
DEVICE="gpu"
else
DEVICE="cpu"
endif

STAGED := $(shell git diff --cached --name-only --diff-filter=ACMR -- 'src/***.py' | sed 's| |\\ |g')

all: format lint
echo 'Makefile for meta-learning-for-everyone repository'

format:
black . --line-length 104
isort .
black .
isort .
nbqa black .
nbqa isort .

lint:
env PYTHONPATH=src/rl2 pytest src/rl2 --pylint --flake8 --mypy
env PYTHONPATH=src/maml pytest src/maml --pylint --flake8 --mypy
env PYTHONPATH=src/pearl pytest src/pearl --pylint --flake8 --mypy
pytest src/ --pylint --flake8 --ignore=src/meta_rl/envs
# nbqa pytest src/ --pylint --flake8

lint-all:
pytest src/ --pylint --flake8 --ignore=src/meta_rl/envs --cache-clear
# nbqa pytest src/ --pylint --flake8 --cache-clear

lint-staged:
ifdef STAGED
pytest $(STAGED) --pylint --flake8 --ignore=src/meta_rl/envs --cache-clear
# nbqa pytest $(STAGED) --pylint --flake8 --cache-clear
else
@echo "No Staged Python File in the src folder"
endif

init:
pip install -U pip
pip install -U setuptools
pip install -e .
pip install -r requirements-common.txt
pip install -r requirements-$(DEVICE).txt
bash ./hooks/install.sh

setup:
pip install -r requirements.txt
pre-commit install
init-dev:
make init
pip install -r requirements-dev.txt
39 changes: 4 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
<div align="center">
<br>
<img src="./img/meta-rl.png" width="500">
</div>

[Image source](https://cs330.stanford.edu/slides/cs330_lifelonglearning_karol.pdf)

<br>

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8.8](https://img.shields.io/badge/python-3.8.8-blue.svg)](https://www.python.org/downloads/release/python-388/)
[![PyTorch 1.8.0](https://img.shields.io/badge/pytorch-1.8.0-red.svg)](https://pytorch.org/blog/pytorch-1.8-released/)
[![PyTorch 1.8.1](https://img.shields.io/badge/pytorch-1.8.0-red.svg)](https://pytorch.org/blog/pytorch-1.8-released/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/imports-isort-white)](https://pycqa.github.io/isort/)
[![Linting: flake8 & mypy & pylint](https://img.shields.io/badge/linting-flake8%20%26%20mypy%20%26%20pylint-deepblue)](https://pypi.org/project/pytest-pylint/)
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)

# Meta-Reinforcement Learning Algorithms with PyTorch
# 모두를 위한 메타러닝: PyTorch를 활용한 Few-shot 학습 모델과 빠른 강화학습 에이전트 만들기

This repository contains PyTorch implementations of meta-reinforcement learning algorithms.

Expand All @@ -25,36 +16,14 @@ This repository is implemented and verified on **python 3.8.8**

## Installation

To run on **pytorch 1.8.0**, enter the [pytorch version link](https://pytorch.org/get-started/previous-versions/#wheel) and run the installation command to desired specifications.
To run on **pytorch 1.8.1**, enter the [pytorch version link](https://pytorch.org/get-started/previous-versions/#wheel) and run the installation command to desired specifications.

Next, clone this repository and run the following command.

```shell
$ make setup
```

## Python Path

To set python path, move to `meta-rl/`.

```shell
$ cd meta-rl
```

If setting python path on `bashrc`:

```shell
$ echo "export META_HOME=$(pwd)" >> ~/.bashrc
$ echo 'export PYTHONPATH=$META_HOME:$PYTHONPATH' >> ~/.bashrc
```

If setting python path on `zshrc`:

```shell
$ echo "export META_HOME=$(pwd)" >> ~/.zshrc
$ echo 'export PYTHONPATH=$META_HOME:$PYTHONPATH' >> ~/.zshrc
```

## Usages

The repository's high-level structure is:
Expand Down Expand Up @@ -123,4 +92,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
8 changes: 8 additions & 0 deletions hooks/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-

REPO_ROOT=$(git rev-parse --show-toplevel)

# Install pre-commit
rm -f $REPO_ROOT/.git/hooks/pre-commit && rm -f $REPO_ROOT/.git/hooks/pre-commit.legacy
pip install pre-commit
cd $REPO_ROOT && pre-commit install
Binary file removed img/meta-rl.png
Binary file not shown.
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# According to PEP-518, https://www.python.org/dev/peps/pep-0518/
#
[build-system]
# Minimum requirements for the build system to execute, according to PEP-508
requires = [
"build>=0.7",
"setuptools>=59.4",
"wheel>=0.37"
]
build-backend = "setuptools.build_meta"

[requires]
python_version = "3.8"

[tool.black]
line-length = 104
target-version = ["py38"]
exclude = ""

[tool.isort]
profile = "black"
skip_gitignore = true
extend_skip_glob = ""

[tool.mypy]
disallow_subclassing_any = false
disallow_untyped_decorators = false
ignore_missing_imports = true
no_site_packages = true
strict = true
6 changes: 6 additions & 0 deletions requirements-common.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gym>=0.24.1
higher>=0.2.1
mujoco-py>=2.1.2.14
tensorflow-tensorboard==1.5.1
torchmeta>=1.8.0
tqdm>=4.62.3
3 changes: 3 additions & 0 deletions requirements-cpu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-f https://download.pytorch.org/whl/torch_stable.html

torch>=1.8.1
Loading

0 comments on commit 77fab64

Please sign in to comment.