Skip to content

Commit

Permalink
Add Devcontainer, handle DomainSets 0.7 (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiahpslewis authored Mar 3, 2024
1 parent 075d2b1 commit 54ace04
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM julia:1.10

RUN apt-get update && apt-get install -y git
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"customizations": {
"vscode": {
"extensions": [
"julialang.language-julia"
]
}
},
"runArgs": [
"--privileged"
],
"dockerFile": "Dockerfile",
"updateContentCommand": "julia -e 'using Pkg; Pkg.develop(path=\"src/ReinforcementLearningBase\"); Pkg.develop(path=\"src/ReinforcementLearningEnvironments\"); Pkg.develop(path=\"src/ReinforcementLearningCore\"); Pkg.develop(path=\"src/ReinforcementLearningZoo\");'"
}
34 changes: 17 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ jobs:
- x64
# - arm64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -50,7 +50,7 @@ jobs:
${{ runner.os }}-
- name: Get changed files
id: RLBase-changed
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@v42
with:
files: |
src/ReinforcementLearningBase/**
Expand Down Expand Up @@ -79,14 +79,14 @@ jobs:
- x64
# - arm64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -98,7 +98,7 @@ jobs:
${{ runner.os }}-
- name: Get changed files
id: RLCore-changed
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@v42
with:
files: |
src/ReinforcementLearningCore/**
Expand Down Expand Up @@ -130,14 +130,14 @@ jobs:
- x64
# - arm64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -149,7 +149,7 @@ jobs:
${{ runner.os }}-
- name: Get changed files
id: RLZoo-changed
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@v42
with:
files: |
src/ReinforcementLearningZoo/**
Expand Down Expand Up @@ -183,14 +183,14 @@ jobs:
- x64
# - arm64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -202,7 +202,7 @@ jobs:
${{ runner.os }}-
- name: Get changed files
id: RLEnvironments-changed
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@v42
with:
files: |
src/ReinforcementLearningEnvironments/**
Expand Down Expand Up @@ -238,14 +238,14 @@ jobs:
- x64
# - arm64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -258,7 +258,7 @@ jobs:
- name: Get changed files
id: RLExperiments-changed
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@v42
with:
files: |
src/ReinforcementLearningExperiments/**
Expand All @@ -283,12 +283,12 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: documentation-changed
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@v42
with:
files: |
docs/**
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
spellchecking:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Check out the code
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
name: Run spell check
with:
node-version: "14"
node-version: "21"
- run: npm install -g cspell
- run: cspell --config ./.cspell/cspell.json "**/*.jl" "**/*.md"
4 changes: 2 additions & 2 deletions src/DistributedReinforcementLearning/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/checkout@v4
env:
cache-name: cache-artifacts
with:
Expand Down
2 changes: 1 addition & 1 deletion src/ReinforcementLearningBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
AbstractTrees = "0.3, 0.4"
CommonRLInterface = "^0.3.2"
CommonRLSpaces = "0.2"
DomainSets = "0.6"
DomainSets = "0.7"
Reexport = "1"
julia = "1.3"

Expand Down
2 changes: 2 additions & 0 deletions src/ReinforcementLearningBase/src/base.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import DomainSets

#####
# printing
#####
Expand Down
22 changes: 22 additions & 0 deletions src/ReinforcementLearningBase/src/space.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export ArrayProductDomain

import DomainSets
import Base.==

@reexport using DomainSets: ×, (..), fullspace, TupleProductDomain

struct ArrayProductDomain{A<:AbstractArray,DD<:AbstractArray} <: DomainSets.ProductDomain{A}
Expand Down Expand Up @@ -31,6 +33,16 @@ DomainSets.toexternalpoint(d::ArrayProductDomain, y) =

DomainSets.promote_pair(x::AbstractArray, d::DomainSets.Domain{<:AbstractArray}) = x, d

# NOTE: This is a patch to maintain current behavior while using DomainSets >=0.7
function ==(a1::ArrayProductDomain, a2::ArrayProductDomain)
try
return isequaldomain(a1, a2)
catch e
@warn "Use StaticArrays (e.g. SVector, SMatrix, or SArray when constructing `ArrayProductDomain` objects." maxlog=1
return typeof(a1) == typeof(a2)
end
end

#####
export NamedTupleProductDomain

Expand All @@ -45,6 +57,16 @@ function NamedTupleProductDomain(; kv...)
NamedTupleProductDomain(t, name2ind)
end

# NOTE: This is a patch to maintain current behavior while using DomainSets >=0.7
function ==(a1::NamedTupleProductDomain, a2::NamedTupleProductDomain)
try
return isequaldomain(a1, a2)
catch e
@warn "Use StaticArrays (e.g. SVector, SMatrix, or SArray when constructing `NamedTupleProductDomain` objects." maxlog=1
return typeof(a1) == typeof(a2)
end
end

DomainSets.components(d::NamedTupleProductDomain) = components(d.tuple_product_domain)
Base.getindex(d::NamedTupleProductDomain, x::Symbol) = components(d)[d.name2ind[x]]
Base.getindex(d::NamedTupleProductDomain, x::Int) = components(d)[x]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function Base.show(io::IO, m::MIME"image/png", env::AtariEnv)
show(io, m, p)
end

Base.show(io::IO, t::MIME"text/plain", env::AbstractEnv) = show(
Base.show(io::IO, t::MIME"text/plain", env::AtariEnv) = show(
IOContext(io, :is_show_state => false, :is_show_state_space => false),
MIME"text/markdown"(),
env,
Expand Down

0 comments on commit 54ace04

Please sign in to comment.