-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from UoA-CARES/rf/type-hints-linting
type hinting + linting across the board
- Loading branch information
Showing
22 changed files
with
952 additions
and
777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Lint | ||
run-name: ${{ github.actor }} is linting the code | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: psf/black@stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Pylint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pylint | ||
- name: Clone cares_reinforcement_learning repository | ||
uses: GuillaumeFalourd/clone-github-repo-action@main | ||
with: | ||
owner: 'UoA-CARES' | ||
repository: 'cares_reinforcement_learning' | ||
|
||
- name: Install cares_reinforcement_learning repository content | ||
run: | | ||
cd cares_reinforcement_learning | ||
pip install -r requirements.txt | ||
pip install --editable . | ||
cd - | ||
- name: Install deps | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Analysing the code with pylint | ||
run: | | ||
pylint $(git ls-files '*.py') --rcfile .pylintrc --fail-under=9 --fail-on=error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[MESSAGES CONTROL] | ||
disable= | ||
logging-fstring-interpolation, | ||
too-few-public-methods, | ||
missing-module-docstring, | ||
missing-function-docstring, | ||
missing-class-docstring, | ||
too-many-locals, | ||
W0511, | ||
too-many-arguments, | ||
|
||
[FORMAT] | ||
max-line-length=130 | ||
|
||
[MASTER] | ||
extension-pkg-whitelist=cv2 | ||
|
||
[TYPECHECK] | ||
generated-members=cv2.* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import logging | ||
|
||
from envrionments.dmcs.dmcs_environment import DMCSEnvironment | ||
from envrionments.gym_environment import GymEnvironment | ||
from envrionments.image_wrapper import ImageWrapper | ||
from envrionments.openai.openai_environment import OpenAIEnvrionment | ||
from envrionments.pyboy.mario.mario_environment import MarioEnvironment | ||
from envrionments.pyboy.pokemon.pokemon_environment import PokemonEnvironment | ||
from util.configurations import GymEnvironmentConfig | ||
|
||
|
||
def create_pyboy_environment(config: GymEnvironmentConfig) -> GymEnvironment: | ||
# TODO extend to other pyboy games...maybe another repo? | ||
if config.task == "pokemon": | ||
env = PokemonEnvironment(config) | ||
elif config.task == "mario": | ||
env = MarioEnvironment(config) | ||
else: | ||
raise ValueError(f"Unkown pyboy environment: {config.task}") | ||
return env | ||
|
||
|
||
class EnvironmentFactory: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def create_environment(self, config: GymEnvironmentConfig) -> GymEnvironment: | ||
logging.info(f"Training Environment: {config.gym}") | ||
if config.gym == "dmcs": | ||
env = DMCSEnvironment(config) | ||
elif config.gym == "openai": | ||
env = OpenAIEnvrionment(config) | ||
elif config.gym == "pyboy": | ||
env = create_pyboy_environment(config) | ||
else: | ||
raise ValueError(f"Unkown environment: {config.gym}") | ||
return ImageWrapper(env) if config.image_observation else env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.