Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update actions and pre commit #62

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ jobs:
- uses: actions/setup-python@v5

- name: Install dependencies
run: python -m pip install --upgrade pip setuptools build

run: pipx install build
- name: Build sdist and wheels
run: python -m build

run: pyproject-build
- name: Store wheels
uses: actions/upload-artifact@v4
with:
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- run: python -m pip install pre-commit
- run: python -m pre_commit --version
- run: python -m pre_commit install
- run: python -m pre_commit run --all-files
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: pipx install pre-commit
- run: pre-commit run --all-files
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-symlinks
- id: destroyed-symlinks
Expand All @@ -17,13 +17,13 @@ repos:
- id: detect-private-key
- id: debug-statements
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
args:
- --ignore-words-list=reacher, mor, nowe
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
args:
Expand All @@ -34,16 +34,16 @@ repos:
- --show-source
- --statistics
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.18.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/python/black
rev: 23.9.1
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pycqa/pydocstyle
Expand Down
1 change: 1 addition & 0 deletions momaland/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Environment modules for momaland."""

import momaland.envs.beach
1 change: 1 addition & 0 deletions momaland/envs/beach/mobeach_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Beach domain environment for multi-objective optimization."""

from momaland.envs.beach.beach import env, parallel_env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/breakthrough/breakthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
| Observation Values | [0,1] |
| Reward Shape | (num_objectives=4,) |
"""

from __future__ import annotations

from typing_extensions import override
Expand Down
1 change: 1 addition & 0 deletions momaland/envs/breakthrough/mobreakthrough_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Breakthrough environment with multiple objectives."""

from momaland.envs.breakthrough.breakthrough import env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/connect4/connect4.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
| Observation Values | [0,1] |
| Reward Shape | (2,) or (2+board_width,) |
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions momaland/envs/connect4/moconnect4_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Connect 4 environment with multiple objectives."""

from momaland.envs.connect4.connect4 import env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/crazyrl/catch/catch_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CrazyRL/Catch environment for MOMARL."""

from momaland.envs.crazyrl.catch.catch import env, parallel_env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/crazyrl/crazyRL_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Base environment inheriting from pettingZoo Parallel environment class."""

from copy import copy
from typing import Optional
from typing_extensions import override
Expand Down
1 change: 1 addition & 0 deletions momaland/envs/crazyrl/escort/escort_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CrazyRL/Escort environment for MOMARL."""

from momaland.envs.crazyrl.escort.escort import env, parallel_env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/crazyrl/gl_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Graphical representation of the UAV in 3D space. the reference is based on the Crazyflie position reference: https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/functional-areas/lighthouse/terminology_definitions/ ."""

import numpy as np
from OpenGL.GL import (
GL_LINES,
Expand Down
1 change: 1 addition & 0 deletions momaland/envs/crazyrl/surround/surround.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Surround environment for Crazyflie 2. Each agent is supposed to learn to surround a common target point."""

from typing_extensions import override

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions momaland/envs/crazyrl/surround/surround_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CrazyRL/Surround environment for MOMARL."""

from momaland.envs.crazyrl.surround.surround import env, parallel_env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/gem_mining/mogem_mining_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Gem mining environment for multi-objective optimization."""

from momaland.envs.gem_mining.gem_mining import env, parallel_env, raw_env


Expand Down
8 changes: 5 additions & 3 deletions momaland/envs/ingenious/ingenious.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ def __init__(
"board": Box(
0, len(ALL_COLORS), shape=(2 * self.board_size - 1, 2 * self.board_size - 1), dtype=np.float32
),
"racks": Box(0, self.num_colors, shape=(num_agents, self.init_draw, 2), dtype=np.int32)
if self.fully_obs
else Box(0, self.num_colors, shape=(self.init_draw, 2), dtype=np.int32),
"racks": (
Box(0, self.num_colors, shape=(num_agents, self.init_draw, 2), dtype=np.int32)
if self.fully_obs
else Box(0, self.num_colors, shape=(self.init_draw, 2), dtype=np.int32)
),
"scores": Box(0, self.game.max_score, shape=(num_agents, self.num_colors), dtype=np.int32),
}
),
Expand Down
16 changes: 13 additions & 3 deletions momaland/envs/ingenious/ingenious_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,12 @@ def check_two_team():
ig_env.step(action)
observation, reward, termination, truncation, _ = ig_env.last()
print("Observations: ", observation["observation"])
print("Rewards: ", reward, "_accumulate_reward(from gymnasium code)", ig_env._cumulative_rewards)
print(
"Rewards: ",
reward,
"_accumulate_reward(from gymnasium code)",
ig_env._cumulative_rewards,
)
print("Truncation: ", truncation)
print("Termination: ", termination)
done = truncation or termination
Expand Down Expand Up @@ -372,7 +377,12 @@ def check_collaborative():
ig_env.step(action)
observation, reward, termination, truncation, _ = ig_env.last()
print("Observations: ", observation["observation"])
print("Rewards: ", reward, "_accumulate_reward(from gymnasium code)", ig_env._cumulative_rewards)
print(
"Rewards: ",
reward,
"_accumulate_reward(from gymnasium code)",
ig_env._cumulative_rewards,
)
print("Truncation: ", truncation)
print("Termination: ", termination)
done = truncation or termination
Expand Down Expand Up @@ -441,5 +451,5 @@ def check_parameter_range():
# check collaborative mode through simulation, it could be found that every players always share the same score in score board.
check_collaborative()

# check parameter range by ramdom choose.
# check parameter range by random choice.
check_parameter_range()
1 change: 1 addition & 0 deletions momaland/envs/ingenious/moingenious_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Multi-objective Ingenious Game."""

from momaland.envs.ingenious.ingenious import env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/item_gathering/moitem_gathering_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Item Gathering environment for multi-objective optimization."""

from momaland.envs.item_gathering.item_gathering import env, parallel_env, raw_env


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Multiwalker-Stability domain environment for MOMARL."""

from momaland.envs.multiwalker_stability.momultiwalker_stability import (
env,
parallel_env,
Expand Down
1 change: 1 addition & 0 deletions momaland/envs/route_choice/moroute_choice_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Route choice environment for multi-objective optimization."""

from momaland.envs.route_choice.route_choice import env, parallel_env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/envs/route_choice/networks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* "od": a list of possible origin-destination (OD) pairs in the network
* "routes": a dictionary which contains routes for OD-pairs
"""

import json
import os

Expand Down
1 change: 1 addition & 0 deletions momaland/envs/samegame/mosame_game_v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Connect 4 environment with multiple objectives."""

from momaland.envs.samegame.same_game import env, raw_env


Expand Down
1 change: 1 addition & 0 deletions momaland/learning/iql/pf_bpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- exp1: 50 agents, 5 sections, 3 capacity, type distribution [35, 15]
- exp2: 100 agents, 5 sections, 5 capacity, type distribution [70, 30]
"""

import argparse
from itertools import product

Expand Down
1 change: 1 addition & 0 deletions momaland/learning/iql/train_iql_bpd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Train IQL on the Beach Problem Domain, under linear scalarization, and save the results to a csv file."""

import argparse
import random
import time
Expand Down
1 change: 1 addition & 0 deletions momaland/learning/iql/train_iql_route_choice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Train IQL on the route choice problem domain, under linear scalarization, and save the results to a csv file."""

import argparse
import os
import random
Expand Down
1 change: 1 addition & 0 deletions momaland/test/wrapper_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Testing file for the wrappers."""

import numpy as np

import momaland.utils.aec_wrappers as AECWrappers
Expand Down
1 change: 1 addition & 0 deletions momaland/utils/aec_wrappers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Various wrappers for AEC MO environments."""

from typing import Optional

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions momaland/utils/env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Overrides PZ types to enforce multi objective rewards."""

import warnings
from typing import Dict
from typing_extensions import override
Expand Down
1 change: 1 addition & 0 deletions momaland/utils/parallel_wrappers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Various wrappers for Parallel MO environments."""

from collections import namedtuple
from typing import Optional

Expand Down
Empty file added py.typed
Empty file.
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ learning = [
"tqdm >=4.66.1",
"pandas >=2.0.3",
"matplotlib >=3.7.4",
"morl_baselines[all]"
"morl_baselines[all]",
"pycddlib==2.1.6",
]
all = [
# All dependencies above except accept-rom-license
Expand All @@ -76,7 +77,8 @@ all = [
"tqdm >=4.66.1",
"pandas >=2.0.3",
"matplotlib >=3.7.4",
"morl_baselines[all]"
"morl_baselines[all]",
"pycddlib==2.1.6",
]
testing = ["pytest ==7.1.3"]

Expand All @@ -93,15 +95,15 @@ include-package-data = true
include = ["momaland", "momaland.*"]

[tool.setuptools.package-data]
mo_gymnasium = [
momaland = [
"**/*.json",
"**/assets/*",
"py.typed",
]

# Linters and Test tools #######################################################

[tool.black]
safe = true
line-length = 127
target-version = ['py38', 'py39', 'py310', 'py311']
include = '\.pyi?$'
Expand Down
Loading