Skip to content

Commit

Permalink
Editor displays gymlib correctly (#63)
Browse files Browse the repository at this point in the history
**Summary**: The editor is now able to find the gymlib library and
display the types correctly.

**Demo**:
Works in dbgym.
<img width="455" alt="Screenshot 2024-12-25 at 19 36 46"
src="https://github.com/user-attachments/assets/22efa678-7267-4d62-858a-c24a2bd382a0"
/>

Works in hello-tune agent.
<img width="450" alt="Screenshot 2024-12-25 at 19 36 50"
src="https://github.com/user-attachments/assets/87ebe1aa-6293-4f0c-abcc-a8bafba07062"
/>


**Details**:
* In the previous PR we got the system running but the editor didn't
display it correctly.
* This works in both dbgym and agent.
  • Loading branch information
wangpatrick57 authored Dec 26, 2024
1 parent 4db0947 commit 3b304aa
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install dependencies
run: |
pip install -r ./scripts/configs/requirements.txt
pip install -e ./gymlib
pip install ./gymlib_package
./scripts/install_sysdeps.sh
- name: Check formatting
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ __pycache__/
.mypy_cache/
.conda/
.idea/
build/
test_clean_scratchspace/
workspace/
default_*_benchbase_config_*.xml
Expand Down
File renamed without changes.
File renamed without changes.
Empty file added gymlib_package/gymlib/py.typed
Empty file.
7 changes: 3 additions & 4 deletions gymlib/pyproject.toml → gymlib_package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "gymlib"
version = "0.1.0"
requires-python = ">=3.8"
dependencies = []

[tool.setuptools]
py-modules = ["gymlib"]
[tool.setuptools.packages.find]
where = ["."]
include = ["gymlib*"]
3 changes: 3 additions & 0 deletions lab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import gymlib

print(gymlib.magic.get_magic_number())
13 changes: 7 additions & 6 deletions scripts/_build_conda_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fi
if [ -f "$python_version_path" ]; then
python_version=$(cat "$python_version_path")
else
echo "Warning: .python_version not found in $python_version_path. Using default Python 3.10."
echo "Info: .python_version not found in $python_version_path. Using default Python 3.10."
python_version="3.10"
fi

Expand All @@ -56,15 +56,16 @@ if [ -f "$requirements_path" ]; then
echo "Installing pip requirements from $requirements_path..."
pip install -r "$requirements_path"
else
echo "Warning: $requirements_path not found. Skipping pip install."
echo "Info: $requirements_path not found. Skipping pip install."
fi

# We always install gymlib so that the agent has access to it.
if [ -d "gymlib" ]; then
echo "Installing gymlib in editable mode..."
pip install -e ./gymlib
if [ -d "gymlib_package" ]; then
echo "Installing gymlib..."
# Note that I don't use -e here. When I tried -e, the editor wouldn't be able to find gymlib.
pip install ./gymlib_package
else
echo "Error: gymlib directory not found in $(pwd). Please ensure you're running this script from the right folder."
echo "Error: gymlib_package directory not found in $(pwd). Please ensure you're running this script from the right folder."
exit 1
fi

Expand Down
3 changes: 2 additions & 1 deletion scripts/mypy.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# Ignore agents/ because those are all submodules.
mypy --config-file scripts/configs/mypy.ini . --exclude agents/
# Ignore gymlib_package/build/ to avoid the error of mypy finding two gymlib packages.
mypy --config-file scripts/configs/mypy.ini . --exclude agents/ --exclude gymlib_package/build/

0 comments on commit 3b304aa

Please sign in to comment.