Skip to content

Commit

Permalink
Support Python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
saridormi committed Apr 2, 2024
1 parent 3bef5de commit af72559
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 29 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Currently, only installation from source is supported:
pip install git+https://github.com/JetBrains-Research/planning-library.git@saridormi-dev
```

If you do not wish to install

## Quick Tour

> :construction: Subject to change
Expand Down
50 changes: 22 additions & 28 deletions environments/frozen_lake/common/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ def _convert_frozenlake_observation_to_position(

@staticmethod
def _convert_direction_to_frozenlake(direction: str) -> int:
match direction:
case "left":
return 0
case "down":
return 1
case "right":
return 2
case "up":
return 3
case _:
raise ValueError(f"Wrong tool input {direction}.")
if direction == "left":
return 0
elif direction == "down":
return 1
elif direction == "right":
return 2
elif direction == "up":
return 3
else:
raise ValueError(f"Wrong tool input {direction}.")

def _run(
self,
Expand Down Expand Up @@ -105,23 +104,18 @@ def _run(
observation=self.env.get_wrapper_attr("s"), nrow=nrow
)

match direction:
case "left":
observation = "out of bounds" if x == 0 else board[x - 1][y].decode()
case "right":
observation = (
"out of bounds" if x == nrow - 1 else board[x + 1][y].decode()
)
case "down":
observation = (
"out of bounds" if y == nrow - 1 else board[x][y + 1].decode()
)
case "up":
observation = "out of bounds" if y == 0 else board[x][y - 1].decode()
case _:
raise ValueError(
"Wrong direction; expected one of: 'left', 'right', 'down', 'up'."
)
if direction == "left":
observation = "out of bounds" if x == 0 else board[x - 1][y].decode()
elif direction == "right":
observation = "out of bounds" if x == nrow - 1 else board[x + 1][y].decode()
elif direction == "down":
observation = "out of bounds" if y == nrow - 1 else board[x][y + 1].decode()
elif direction == "up":
observation = "out of bounds" if y == 0 else board[x][y - 1].decode()
else:
raise ValueError(
"Wrong direction; expected one of: 'left', 'right', 'down', 'up'."
)

info: Dict[str, Any]
reward, terminated, truncated, info = (
Expand Down
3 changes: 2 additions & 1 deletion planning_library/action_executors/base_action_executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import List, overload, Sequence, Optional

from langchain_core.agents import AgentAction, AgentStep
from langchain_core.tools import BaseTool
from langchain_core.callbacks import CallbackManager, AsyncCallbackManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import List, overload, Sequence, Optional

from langchain_core.agents import AgentAction, AgentStep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import List, Optional, Tuple, overload, Sequence

import gymnasium as gym
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional, Tuple

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional, Tuple

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import Dict, List, Optional, Tuple

from langchain_core.agents import AgentAction, AgentFinish
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import asyncio
from abc import ABC, abstractmethod
from typing import Dict, List, Literal, Optional, Tuple, overload
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Tuple

Expand Down
1 change: 1 addition & 0 deletions planning_library/strategies/tot_dfs/tot_strategy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from collections import deque
from typing import (
AsyncIterator,
Expand Down

0 comments on commit af72559

Please sign in to comment.