Skip to content

Commit

Permalink
0.1.5 release (#32)
Browse files Browse the repository at this point in the history
* initial soft prompt example for stage 3 trlx (#14)

* initial softprompt example for stage 3 trlx

* clean up

* basic runnable changes after trlx pr merge

* softprompt prefix padding handling, whole model freezing, cleanup

* new toy tasks, restored config register, plot softprompt drift

* fix import

* minor fixes, +orchestrator to handle softprompt padding

* update for new trlx version

* fix(sandbox): build typo and updating lock file (#26)

* Fix dependency for box2d; Moved graphviz stuff to optional. (#27)

* update and cleanup for latest trlx, clarity

* bugfix: override get_model_inputs with softprompt support

* additional comments, sanity checks

* update configs and example scripts

* init readme for trlx softprompt tuning setup

* formatting

* fix filename typo

Co-authored-by: Francisco Carvalho <[email protected]>
Co-authored-by: Honglu Fan <[email protected]>

* Diff processing and evaluations (#29)

* fix(sandbox): build typo and updating lock file (#26)

* Fix dependency for box2d; Moved graphviz stuff to optional. (#27)

* Added a few diff util functions and tests; Added pytest to CI; Added box2d-py (for pytest to pass) and requests to requirements.txt.

* fix pytest.

* ugh, dependency...

* fix typo... (ugh probably drank too much)

* fix dependency.

* added torch to requirements.txt

* Expose `Genotype` and `BaseEnvironment` for others to inherit.

* Use `checkpoints_dir` in the config instead of hardcoding "checkpoints".

* Fix small bug in ImageOptim mutate.

* Modified benchmark config; Added diff benchmark script; Completed verify_diff and added tests.

* Fixed minor issues on device and invalid format.

* Force `.use_cache` to be True.

* Rename `elm.py` into `elm_main.py` to avoid conflicts in import.

* Minor changes according to review; Added `DiffState` to represent the validity of diff data sample.

* Fix CI.

* Box2d CI bug again! Trying a hot-fix...

* Another try on swig version.

* Another try on swig version.

* Seriously?? What about revert back.

* Ok, trying again with different install order...

Co-authored-by: Francisco Carvalho <[email protected]>

* Fix requirements

* Add sodarace tests

* fix ADDFILE line count verification.

* Add docs with Sphinx

* Fix readthedocs syntax

* Fix rtd build

* Fix rtd build (for real this time)

* Rename elm to openelm

* Rename util

* Linting

* Revert "Linting"

This reverts commit 8db8623.

* Linting utils

* Add docstrings to some files

* Add Sphinx autodoc specification

* Rename benchmark_diff

* Improve Sphinx docstrings

Co-authored-by: Andrew <[email protected]>
Co-authored-by: Francisco Carvalho <[email protected]>
Co-authored-by: Honglu Fan <[email protected]>
Co-authored-by: Honglu Fan <[email protected]>
  • Loading branch information
5 people authored Dec 23, 2022
1 parent ef4a7ce commit b6b2baa
Show file tree
Hide file tree
Showing 92 changed files with 2,529 additions and 383 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
branches:
- main
- '**release'
- 'release/**'

jobs:
build:
Expand All @@ -25,10 +25,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
python -m pip install .[dev]
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7 --show-source --statistics --max-line-length=88
# Full lint, will not stop the build on failure.
flake8 . --count --exit-zero --ignore=E203,E501,F811 --show-source --statistics --max-line-length=88
- name: Test with pytest
run: |
pytest
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
rev: 22.10.0
hooks:
- id: black
files: ^(elm|test|setup.py)/
files: ^(openelm|test|setup.py)/
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
Expand All @@ -37,3 +37,5 @@ repos:
args:
- '--convention=google'
- '--add-ignore=D10'
- '-v'
- '--count'
28 changes: 28 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Remove report submodule from docs build
submodules:
exclude: all

build:
os: ubuntu-20.04
tools:
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To submit a bug report or a feature request, please open an [issue](https://gith

## Submitting code

> **Note**: Make sure to first search through the [issue tracker](https://github.com/CarperAI/ELM/issues) and [PR list](https://github.com/CarperAI/ELM/pulls) to avoid duplicating work. If you want to work on a non-trivial feature, we highly recommended that you first open an issue in the [issue tracker](https://github.com/CarperAI/ELM/issues) to get feedback from core developers.
> **Note**: Make sure to first search through the [issue tracker](https://github.com/CarperAI/OpenELM/issues) and [PR list](https://github.com/CarperAI/OpenELM/pulls) to avoid duplicating work. If you want to work on a non-trivial feature, we highly recommended that you first open an issue in the [issue tracker](https://github.com/CarperAI/OpenELM/issues) to get feedback from core developers.
Follow these steps to start contributing code:

Expand Down Expand Up @@ -55,7 +55,7 @@ Have a question? Rather than opening an issue, you can readily chat with the cor
## Code of conduct
This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/CarperAI/ELM/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/CarperAI/OpenELM/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
## License
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ Currently, we can run the MAP-Elites algorithm on [a few environments](https://g

## Setting up the sandbox
Ideally, please follow the [sandboxing readme](https://github.com/CarperAI/OpenELM/tree/main/elm/sandbox) to set it up in a docker container. But for quick testing purpose, one may try the following:
```python
```bash
cd elm/sandbox/server
export FLASK_APP=index.py
flask run
```
## Running the MAP-Elites
We have a few toy environments implemented as well as the Sodarace environment in the ELM paper. One may try to run the following (after setting up with the sandbox server in the same machine).
```python
We have a few toy environments implemented as well as the Sodarace environment in the ELM paper. One may try to do the following (after setting up with the sandbox server in the same machine).

First, download the codegen-350M model.
```bash
wget -P checkpoints https://storage.googleapis.com/sfr-codegen-research/checkpoints/codegen-350M-mono.tar.gz && tar -xvf checkpoints/codegen-350M-mono.tar.gz -C checkpoints/
```
Once it is done, run the MAP-Elites with prompt mutations using codegen-350M.
```bash
python3 run_elm.py run_name=test
python3 run_elm.py --config-name=elm_image_cfg run_name=test
```
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
13 changes: 13 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sphinx==5.3.0
sphinx_rtd_theme
sphinx_autodoc_typehints
hydra-core>=1.2.0
wandb>=0.13
numpy
torch>=1.10
transformers>=4.22.0
tokenizers
swig>=4.1.0
box2d-py==2.3.8
requests
Flask
71 changes: 71 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import sphinx_rtd_theme # noqa: F401

sys.path.insert(0, os.path.abspath(".."))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "OpenELM"
copyright = "2022, CarperAI"
author = "CarperAI"
release = "0.1.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.


extensions = [
"sphinx_rtd_theme",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.autosectionlabel",
"sphinx_autodoc_typehints",
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["tests", "logs", "archive", "checkpoints"]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_theme_options = {
"logo_only": True,
"display_version": True,
}

html_favicon = "images/openelm_favicon.ico"
Binary file added docs/source/images/openelm_favicon.ico
Binary file not shown.
21 changes: 21 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. OpenELM documentation master file, created by
sphinx-quickstart on Fri Dec 23 14:05:09 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to OpenELM's documentation!
===================================

.. toctree::
:maxdepth: 2
:caption: Contents:

openelm


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
14 changes: 14 additions & 0 deletions docs/source/openelm.codegen.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
openelm.codegen package
========================

Submodules
-------------------------------------------

Module contents
-------------------------------------------

.. automodule:: openelm.codegen
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__
23 changes: 23 additions & 0 deletions docs/source/openelm.environments.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
openelm.environments package
=============================

Submodules
--------------------------------------

openelm.environments.environments module
-------------------------------------------

.. automodule:: openelm.environments.environments
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__

Module contents
--------------------------------------

.. automodule:: openelm.environments
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__
59 changes: 59 additions & 0 deletions docs/source/openelm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
OpenELM API Reference
======================

Subpackages
-----------

.. toctree::
:maxdepth: 2

openelm.environments
openelm.codegen

Submodules
----------

openelm.elm module
-----------------------------------------

.. automodule:: openelm.elm
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__

openelm.map_elites module
-----------------------------------------

.. automodule:: openelm.map_elites
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__

openelm.diff_model module
-----------------------------------------

.. automodule:: openelm.diff_model
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__

openelm.benchmarks module
-----------------------------------------

.. automodule:: openelm.benchmarks
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__

Module contents
-----------------------------------------

.. automodule:: openelm
:members:
:undoc-members:
:show-inheritance:
:special-members: __init__
21 changes: 0 additions & 21 deletions elm/Pipfile

This file was deleted.

1 change: 0 additions & 1 deletion elm/__init__.py

This file was deleted.

Loading

0 comments on commit b6b2baa

Please sign in to comment.