Skip to content

Commit 699d40e

Browse files
feat(package): fewer dependencies with fewer version pins (#95)
* feat(cli): add builtin fragile swarm solver - drop dependency on fragile library since we need a fixed version, and its deps are OOOOOOOOLD. * feat(package): drop pydantic dependency - we aren't using it for anything (useful) * chore: fragile relative imports 🎉 - tests pass and CLI works and no more numpy/gym heck * chore: fix up numpy errors and test suite - we can swarm with no fragile dep or numpy version pinning :) * chore: drop unused fragile code * chore: fix tests * chore: drop lots more unused fragile code * chore: drop more unused fragile code * chore: more unused code * chore: drop networkx requirement and autoformat code - had to drop history tree 😭 but it will be fine * chore: drop data generation swarm example * feat(ci): add cron builds and matrix testing * chore: update codecov range for mathy repo
1 parent 145612e commit 699d40e

File tree

27 files changed

+4377
-138
lines changed

27 files changed

+4377
-138
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@ on:
77
pull_request:
88
branches:
99
- "*"
10+
schedule:
11+
# Every Monday at 1PM UTC (9AM EST)
12+
- cron: "0 13 * * 1"
1013

1114
jobs:
1215
build:
16+
strategy:
17+
matrix:
18+
os: [ubuntu-20.04]
19+
python-version: [3.7, 3.8, 3.9, 3.10.6, 3.11]
1320
runs-on: ubuntu-latest
1421
steps:
1522
- uses: actions/checkout@v1
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: ${{ matrix.python-version }}
1627
- name: Install Graphviz
1728
run: sudo apt-get install graphviz
1829
- name: Setup Packages

codecov.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
coverage:
22
status:
3-
patch: off
3+
patch: off
4+
precision: 2
5+
round: down
6+
range: "50...100"

libraries/mathy_python/mathy/api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from dataclasses import dataclass
22
from typing import Optional
33

4-
from fragile.core.swarm import Swarm
4+
from .fragile.core.swarm import Swarm
55

66
from .solver import SwarmConfig, swarm_solve
77

@@ -22,6 +22,7 @@ def __init__(
2222
config: Optional[SwarmConfig] = None,
2323
silent: bool = False,
2424
):
25+
self.silent = silent
2526
if config is None:
2627
config = SwarmConfig()
2728
if not isinstance(config, SwarmConfig):
@@ -30,5 +31,7 @@ def __init__(
3031

3132
def simplify(self, *, problem: str, max_steps: Optional[int] = None) -> Swarm:
3233
if max_steps is not None:
33-
return swarm_solve(problem, self.state.config, max_steps=max_steps)
34-
return swarm_solve(problem, self.state.config)
34+
return swarm_solve(
35+
problem, self.state.config, max_steps=max_steps, silent=self.silent
36+
)
37+
return swarm_solve(problem, self.state.config, silent=self.silent)

libraries/mathy_python/mathy/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ def cli_print_problems(environment: str, difficulty: str, number: int):
7878
This is useful if you when developing new environment types for
7979
verifying that the problems you're generating take the form you
8080
expect. """
81-
import gym
81+
import gymnasium as gym
8282
from mathy_envs.gym import MathyGymEnv
8383

8484
env_name = f"mathy-{environment}-{difficulty}-v0"
85-
env: MathyGymEnv = gym.make(env_name) # type:ignore
85+
env: MathyGymEnv = gym.make(env_name).unwrapped # type:ignore
8686
msg.divider(env_name)
8787
with msg.loading(f"Generating {number} problems..."):
8888
header = ("Complexity", "Is Valid", "Text")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Framework for FAI algorithms development."""
2+
3+
import warnings
4+
5+
warnings.filterwarnings(
6+
"ignore",
7+
message=(
8+
"Using or importing the ABCs from 'collections' instead of from 'collections.abc' "
9+
"is deprecated since Python 3.3,and in 3.9 it will stop working"
10+
),
11+
)
12+
warnings.filterwarnings(
13+
"ignore",
14+
message=(
15+
"the imp module is deprecated in favour of importlib; see the module's "
16+
"documentation for alternative uses"
17+
),
18+
)
19+
warnings.filterwarnings(
20+
"ignore",
21+
message=(
22+
"Using or importing the ABCs from 'collections' instead of from "
23+
"'collections.abc' is deprecated, and in 3.8 it will stop working"
24+
),
25+
)
26+
warnings.filterwarnings(
27+
"ignore",
28+
message=(
29+
"The set_clim function was deprecated in Matplotlib 3.1 "
30+
"and will be removed in 3.3. Use ScalarMappable.set_clim "
31+
"instead."
32+
),
33+
)
34+
warnings.filterwarnings("ignore", message="Gdk.Cursor.new is deprecated")
35+
36+
from .core.states import States # noqa: E402
37+
from .core.walkers import Walkers # noqa: E402
38+
from .version import __version__ # noqa: E402
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Core base classes for developing FAI algorithms."""
2+
from .base_classes import BaseCritic, BaseWrapper
3+
from .bounds import Bounds
4+
from .env import DiscreteEnv, Environment
5+
from .models import (
6+
BinarySwap,
7+
ContinuousUniform,
8+
DiscreteUniform,
9+
Model,
10+
NormalContinuous,
11+
)
12+
from .states import OneWalker, States, StatesEnv, StatesModel, StatesWalkers
13+
from .swarm import Swarm
14+
from .walkers import Walkers
15+
from .wrappers import EnvWrapper

0 commit comments

Comments
 (0)