Skip to content

Commit

Permalink
Merge latest master into v0.3 (#426)
Browse files Browse the repository at this point in the history
* update docker hub init (#367)

* update docker hub init

* replace personal account with maro-team

* update hello files for CIM

* update docker repository name

* update docker file name

* fix bugs in notebook, rectify docs

* fix doc build issue

* remove docs from playground; fix citibike lp example Event issue

* update the exampel for vector env

* update vector env example

* update README due to PR comments

* add link to playground above MARO installation in README

* fix some typos

Co-authored-by: Jinyu Wang <Wang.Jinyu@microsoft.com>

* update package version

* update README for package description

* update image links for pypi package description

* update image links for pypi package description

* change the input topology schema for CIM real data mode (#372)

* change the input topology schema for CIM real data mode

* remove unused importing

* update test config file correspondingly

* add Exception for env test

* add cost factors to cim data dump

* update CimDataCollection field name

* update field name of data collection related code

* update package version

* adjust interface to reflect actual signature (#374)

Co-authored-by: Jeremy Reynolds <jeremr@microsoft.com>

* update dataclasses requirement to setup

* fix: fixing spelling grammarr

* fix: fix typo spelling code commented and data_model.rst

* Fix Geo vis IP address & SQL logic bugs. (#383)

Fix Geo vis IP address & SQL logic bugs (issue [352](#352) and [314](#314)).

* Fix the "Wrong future stop tick predictions" bug (#386)

* Propose my new solution

Refine to the pre-process version

.

* Optimize import

* Fix reset random seed bug (#387)

* update the reset interface of Env and BE

* Try to fix reset routes generation seed issue

* Refine random related logics.

* Minor refinement

* Test check

* Minor

* Remove unused functions so far

* Minor

Co-authored-by: Jinyu Wang <jinywan@microsoft.com>

* update package version

* Add _init_vessel_plans in business_engine.reset (#388)

* update package version

* change the default solver used in Citibike OnlineLP example, from GLPK to CBC (#391)

Co-authored-by: Jinyu Wang <Wang.Jinyu@microsoft.com>

* Refine `event_buffer/` module (#389)

* Core & Business Engine code refinement (#392)

* First version

* Optimize imports

* Add typehint

* Lint check

* Lint check

* add higher python version (#398)

* add higher python version

* update pytorch version

* update torchvision version

Co-authored-by: Jinyu Wang <Wang.Jinyu@microsoft.com>

* CIM scenario refinement (#400)

* Cim scenario refinement (#394)

* CIM refinement

* Fix lint error

* Fix lint error

* Cim test coverage (#395)

* Enrich tests

* Refactor CimDataGenerator

* Refactor CIM parsers

* Minor refinement

* Fix lint error

* Fix lint error

* Fix lint error

* Minor refactor

* Type

* Add two test file folders. Make a slight change to CIM BE.

* Lint error

* Lint error

* Remove unnecessary public interfaces of CIM BE

* Cim disable auto action type detection (#399)

* Haven't been tested

* Modify document

* Add ActionType checking

* Minor

* Lint error

* Action quantity should be a position number

* Modify related docs & notebooks

* Minor

* Change test file name. Prepare to merge into master.

* .

* Minor test patch

* Add `clear()` function to class `SimRandom` (#401)

* Add SimRandom.clear()

* Minor

* Remove commented codes

* Lint error

* update package version

* Minor

* Remove docs/source/examples/multi_agent_dqn_cim.rst

* Update .gitignore

* Update .gitignore

Co-authored-by: Jinyu-W <53509467+Jinyu-W@users.noreply.github.com>
Co-authored-by: Jinyu Wang <Wang.Jinyu@microsoft.com>
Co-authored-by: Jinyu Wang <jinywan@microsoft.com>
Co-authored-by: Jeremy Reynolds <jeremy.reynolds@microsoft.com>
Co-authored-by: Jeremy Reynolds <jeremr@microsoft.com>
Co-authored-by: slowy07 <slowy.arfy@gmail.com>
  • Loading branch information
7 people committed Dec 8, 2021
1 parent 6a1179c commit ff0f706
Show file tree
Hide file tree
Showing 158 changed files with 6,409 additions and 2,839 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/---bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Steps to reproduce the behavior:
- How you installed MARO (`pip`, `source`):
- OS (`Linux`, `Windows`, `macOS`):
- Python version (`3.6`, `3.7`):
- Docker image (e.g., arthursjiang/maro:cpu[5f36ed]):
- Docker image (e.g., maro2020/maro:latest):
- CPU/GPU:
- Any other relevant information:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: |
pip install -r ./maro/requirements.build.txt
cython ./maro/backends/backend.pyx ./maro/backends/np_backend.pyx ./maro/backends/raw_backend.pyx ./maro/backends/frame.pyx --cplus -3 -E NODES_MEMORY_LAYOUT=ONE_BLOCK -X embedsignature=True
cat ./maro/__misc__.py | grep __version__ | egrep -o [0-9].[0-9].[0-9,a-z]+ | { read version; docker build -f ./docker_files/cpu.play.df . -t ${{ secrets.DOCKER_HUB_USERNAME }}/maro:cpu -t ${{ secrets.DOCKER_HUB_USERNAME }}/maro:latest -t ${{ secrets.DOCKER_HUB_USERNAME }}/maro:cpu-$version; }
cat ./maro/__misc__.py | grep __version__ | egrep -o [0-9].[0-9].[0-9,a-z]+ | { read version; docker build -f ./docker_files/cpu.playground.df . -t ${{ secrets.DOCKER_HUB_USERNAME }}/maro:cpu -t ${{ secrets.DOCKER_HUB_USERNAME }}/maro:latest -t ${{ secrets.DOCKER_HUB_USERNAME }}/maro:cpu-$version; }
- name: Login docker hub
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-16.04, ubuntu-18.04, windows-latest, macos-latest]
python-version: [3.6, 3.7]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -39,7 +39,7 @@ jobs:
- name: Install torch on Windows
if: runner.os == 'Windows'
run: |
pip install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch===1.7.1 torchvision===0.8.2 -f https://download.pytorch.org/whl/torch_stable.html
- name: Install test dependencies
run: |
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
[![Platform](https://raw.githubusercontent.com/microsoft/maro/master/docs/source/images/badges/platform.svg)](https://pypi.org/project/pymaro/)
[![Python Versions](https://img.shields.io/pypi/pyversions/pymaro.svg?logo=python&logoColor=white)](https://pypi.org/project/pymaro/#files)
[![Code Size](https://img.shields.io/github/languages/code-size/microsoft/maro)](https://github.com/microsoft/maro)
[![Docker Size](https://img.shields.io/docker/image-size/arthursjiang/maro)](https://hub.docker.com/repository/docker/arthursjiang/maro/tags?page=1)
[![Docker Size](https://img.shields.io/docker/image-size/maro2020/maro)](https://hub.docker.com/repository/docker/maro2020/maro/tags?page=1)
[![Issues](https://img.shields.io/github/issues/microsoft/maro)](https://github.com/microsoft/maro/issues)
[![Pull Requests](https://img.shields.io/github/issues-pr/microsoft/maro)](https://github.com/microsoft/maro/pulls)
[![Dependencies](https://img.shields.io/librariesio/github/microsoft/maro)](https://libraries.io/pypi/pymaro)
[![test](https://github.com/microsoft/maro/workflows/test/badge.svg)](https://github.com/microsoft/maro/actions?query=workflow%3Atest)
[![build](https://github.com/microsoft/maro/workflows/build/badge.svg)](https://github.com/microsoft/maro/actions?query=workflow%3Abuild)
[![docker](https://github.com/microsoft/maro/workflows/docker/badge.svg)](https://hub.docker.com/repository/docker/arthursjiang/maro)
[![docker](https://github.com/microsoft/maro/workflows/docker/badge.svg)](https://hub.docker.com/repository/docker/maro2020/maro)
[![docs](https://readthedocs.org/projects/maro/badge/?version=latest)](https://maro.readthedocs.io/)
[![PypI Versions](https://img.shields.io/pypi/v/pymaro)](https://pypi.org/project/pymaro/#files)
[![Wheel](https://img.shields.io/pypi/wheel/pymaro)](https://pypi.org/project/pymaro/#files)
Expand All @@ -23,8 +23,8 @@
[![Lint](https://github.com/microsoft/maro/workflows/lint/badge.svg)](https://github.com/microsoft/maro/actions?query=workflow%3Alint)
[![Coverage](https://img.shields.io/codecov/c/github/microsoft/maro)](https://codecov.io/gh/microsoft/maro)
[![Downloads](https://img.shields.io/pypi/dm/pymaro)](https://pypi.org/project/pymaro/#files)
[![Docker Pulls](https://img.shields.io/docker/pulls/arthursjiang/maro)](https://hub.docker.com/repository/docker/arthursjiang/maro)
[![Play with MARO](https://raw.githubusercontent.com/microsoft/maro/master/docs/source/images/badges/play_with_maro.svg)](https://hub.docker.com/r/arthursjiang/maro)
[![Docker Pulls](https://img.shields.io/docker/pulls/maro2020/maro)](https://hub.docker.com/repository/docker/maro2020/maro)
[![Play with MARO](https://raw.githubusercontent.com/microsoft/maro/master/docs/source/images/badges/play_with_maro.svg)](https://hub.docker.com/r/maro2020/maro)

# [![MARO LOGO](./docs/source/images/logo.svg)](https://maro.readthedocs.io/en/latest/)

Expand Down Expand Up @@ -58,6 +58,8 @@ of user-defined functions for message auto-handling, cluster provision, and job
| `examples` | Showcase of MARO. |
| `notebooks` | MARO quick-start notebooks. |

*Try [MARO playground](#run-playground) to have a quick experience.*

## Install MARO from [PyPI](https://pypi.org/project/pymaro/#files)

*Notes: The CLI commands (including the visualization tool) are not included in pymaro package. To enable these support, you need to install from source.*
Expand Down Expand Up @@ -185,14 +187,16 @@ maro inspector dashboard --source_path ./dump_data/YOUR_SNAPSHOT_DUMP_FOLDER

## Run Playground

- Pull from [Docker Hub](https://hub.docker.com/repository/registry-1.docker.io/arthursjiang/maro/tags?page=1)
- Pull from [Docker Hub](https://hub.docker.com/r/maro2020/playground)

```sh
# Pull the docker image from docker hub
docker pull maro2020/playground

# Run playground container.
# Redis commander (GUI for redis) -> http://127.0.0.1:40009
# Local host docs -> http://127.0.0.1:40010
# Jupyter lab with maro -> http://127.0.0.1:40011
docker run -p 40009:40009 -p 40010:40010 -p 40011:40011 arthursjiang/maro:cpu
# Jupyter lab with maro -> http://127.0.0.1:40010
docker run -p 40009:40009 -p 40010:40010 maro2020/playground
```

- Build from source
Expand All @@ -204,9 +208,8 @@ maro inspector dashboard --source_path ./dump_data/YOUR_SNAPSHOT_DUMP_FOLDER

# Run playground container.
# Redis commander (GUI for redis) -> http://127.0.0.1:40009
# Local host docs -> http://127.0.0.1:40010
# Jupyter lab with maro -> http://127.0.0.1:40011
docker run -p 40009:40009 -p 40010:40010 -p 40011:40011 maro/playground:cpu
# Jupyter lab with maro -> http://127.0.0.1:40010
docker run -p 40009:40009 -p 40010:40010 maro2020/playground
```

- Windows
Expand All @@ -217,9 +220,8 @@ maro inspector dashboard --source_path ./dump_data/YOUR_SNAPSHOT_DUMP_FOLDER
# Run playground container.
# Redis commander (GUI for redis) -> http://127.0.0.1:40009
# Local host docs -> http://127.0.0.1:40010
# Jupyter lab with maro -> http://127.0.0.1:40011
docker run -p 40009:40009 -p 40010:40010 -p 40011:40011 maro/playground:cpu
# Jupyter lab with maro -> http://127.0.0.1:40010
docker run -p 40009:40009 -p 40010:40010 maro2020/playground
```

## Contributing
Expand Down
62 changes: 22 additions & 40 deletions docker_files/cpu.play.df → docker_files/cpu.playground.df
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
FROM python:3.6
FROM python:3.7

WORKDIR /maro_playground

# Setup notebook
ADD ./notebooks ./notebooks
RUN /usr/local/bin/python -m pip install --upgrade pip
RUN pip install -r ./notebooks/requirements.nb.txt
RUN jupyter contrib nbextension install --system
RUN jt -t onedork -fs 95 -altp -tfs 11 -nfs 115 -cellw 88% -T


# Install redis
RUN wget http://download.redis.io/releases/redis-6.0.6.tar.gz; tar xzf redis-6.0.6.tar.gz; cd redis-6.0.6; make
RUN rm redis-6.0.6.tar.gz

# Install others
# Install zsh and other packages for the terminal usage
RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update
RUN apt-get install -y zsh
RUN apt-get install -y htop
Expand All @@ -23,42 +11,36 @@ RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -
RUN chsh -s `which zsh` && wget https://raw.githubusercontent.com/ArthurJiang/config/master/.zshrc -O ~/.zshrc
RUN apt-get install -y npm
RUN rm -rf /var/lib/apt/lists/*

# Install redis
RUN wget http://download.redis.io/releases/redis-6.0.6.tar.gz; tar xzf redis-6.0.6.tar.gz; cd redis-6.0.6; make
RUN rm redis-6.0.6.tar.gz
RUN npm install -g redis-commander

# Setup notebook
ADD ./notebooks ./notebooks
RUN /usr/local/bin/python -m pip install --upgrade pip
RUN pip install -r ./notebooks/requirements.nb.txt
RUN jupyter contrib nbextension install --system
RUN jt -t onedork -fs 95 -altp -tfs 11 -nfs 115 -cellw 88% -T
RUN rm ./notebooks/*.txt
RUN rm ./notebooks/*.sh

# Add examples
ADD ./examples ./examples
ADD ./examples/requirements.ex.txt ./examples/requirements.ex.txt
RUN pip install -r ./examples/requirements.ex.txt
RUN rm ./examples/requirements.ex.txt

# Add local docs
ADD ./docs ./docs
ADD ./maro ./maro
ADD setup.py setup.py
ADD ./scripts ./scripts
RUN bash scripts/install_maro.sh
RUN pip install -U -r ./docs/requirements.docs.txt
RUN cd docs; make html
RUN rm -rf ./maro
RUN rm setup.py
RUN rm -rf ./scripts
# Install MARO
RUN pip install pymaro
ENV PYTHONPATH ./

# Add run cmd
ADD ./scripts/run_playground.sh ./run.sh

# Add readme
# Add README
ADD ./playground.md ./README.md

# Clean
RUN rm ./notebooks/*.txt
RUN rm ./notebooks/*.sh
RUN rm -r ./docs/source
RUN rm ./docs/make.bat
RUN rm ./docs/Makefile
RUN rm ./docs/README.md
RUN rm ./docs/requirements.docs.txt
RUN rm -rf ./build
RUN rm -rf ./pymaro.egg-info

# Install maro
RUN pip install pymaro

# Start service
CMD ["/bin/bash", "./run.sh"]
4 changes: 2 additions & 2 deletions docs/source/apidoc/maro.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ maro.utils.exception.communication\_exception
:undoc-members:
:show-inheritance:

maro.utils.exception.data\_lib\_exeption
maro.utils.exception.data\_lib\_exception
--------------------------------------------------------------------------------

.. automodule:: maro.utils.exception.data_lib_exeption
.. automodule:: maro.utils.exception.data_lib_exception
:members:
:undoc-members:
:show-inheritance:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/greedy_policy_citi_bike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ This environment is driven by `real trip history data <https://s3.amazonaws.com/
.. note::

All related code snippets are supported in `maro playground <https://hub.docker.com/r/arthursjiang/maro>`_.
All related code snippets are supported in `maro playground <https://hub.docker.com/r/maro2020/playground>`_.
62 changes: 26 additions & 36 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,35 @@ Quick Start
.. code-block:: python
from maro.simulator import Env
from maro.simulator.scenarios.cim.common import Action
from maro.simulator.scenarios.cim.common import Action, ActionType, DecisionEvent
# Initialize an environment with a specific scenario, related topology.
# In Container Inventory Management, 1 tick means 1 day, here durations=100 means a length of 100 days
from random import randint
# Initialize an Env for cim scenario
env = Env(scenario="cim", topology="toy.5p_ssddd_l0.0", start_tick=0, durations=100)
# Query environment summary, which includes business instances, intra-instance attributes, etc.
print(env.summary)
for ep in range(2):
# Gym-like step function.
metrics, decision_event, is_done = env.step(None)
while not is_done:
past_week_ticks = [
x for x in range(decision_event.tick - 7, decision_event.tick)
]
decision_port_idx = decision_event.port_idx
intr_port_infos = ["booking", "empty", "shortage"]
# Query the snapshot list of the environment to get the information of
# the booking, empty container inventory, shortage of the decision port in the past week.
past_week_info = env.snapshot_list["ports"][
past_week_ticks : decision_port_idx : intr_port_infos
]
dummy_action = Action(
vessel_idx=decision_event.vessel_idx,
port_idx=decision_event.port_idx,
quantity=0
)
# Drive environment with dummy action (no repositioning).
metrics, decision_event, is_done = env.step(dummy_action)
# Query environment business metrics at the end of an episode,
# it is your optimized object (usually includes multi-target).
print(f"ep: {ep}, environment metrics: {env.metrics}")
env.reset()
metrics: object = None
decision_event: DecisionEvent = None
is_done: bool = False
action: Action = None
# Start the env with a None Action
metrics, decision_event, is_done = env.step(None)
while not is_done:
# Generate a random Action according to the action_scope in DecisionEvent
action_scope = decision_event.action_scope
to_discharge = action_scope.discharge > 0 and randint(0, 1) > 0
action = Action(
decision_event.vessel_idx,
decision_event.port_idx,
randint(0, action_scope.discharge if to_discharge else action_scope.load),
ActionType.DISCHARGE if to_discharge else ActionType.LOAD
)
# Respond the environment with the generated Action
metrics, decision_event, is_done = env.step(action)
Contents
----------
Expand Down
26 changes: 10 additions & 16 deletions docs/source/installation/playground.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
Playground Docker Image
=======================

Pull from `Docker Hub <https://hub.docker.com/repository/registry-1.docker.io/arthursjiang/maro/tags?page=1>`_
Pull from `Docker Hub <https://hub.docker.com/repository/registry-1.docker.io/maro2020/playground/tags?page=1>`_
------------------------------------------------------------------------------------------------------------------

.. code-block:: sh
# Run playground container.
# Redis commander (GUI for redis) -> http://127.0.0.1:40009
# Local host docs -> http://127.0.0.1:40010
# Jupyter lab with maro -> http://127.0.0.1:40011
docker run -p 40009:40009 -p 40010:40010 -p 40011:40011 arthursjiang/maro:cpu
# Jupyter lab with maro -> http://127.0.0.1:40010
docker run -p 40009:40009 -p 40010:40010 maro2020/playground
Run from Source
---------------
Expand All @@ -25,9 +24,8 @@ Run from Source
# Run playground container.
# Redis commander (GUI for redis) -> http://127.0.0.1:40009
# Local host docs -> http://127.0.0.1:40010
# Jupyter lab with maro -> http://127.0.0.1:40011
docker run -p 40009:40009 -p 40010:40010 -p 40011:40011 maro/playground:cpu
# Jupyter lab with maro -> http://127.0.0.1:40010
docker run -p 40009:40009 -p 40010:40010 maro2020/playground
* Windows

Expand All @@ -38,9 +36,8 @@ Run from Source
# Run playground container.
# Redis commander (GUI for redis) -> http://127.0.0.1:40009
# Local host docs -> http://127.0.0.1:40010
# Jupyter lab with maro -> http://127.0.0.1:40011
docker run -p 40009:40009 -p 40010:40010 -p 40011:40011 maro/playground:cpu
# Jupyter lab with maro -> http://127.0.0.1:40010
docker run -p 40009:40009 -p 40010:40010 maro2020/playground
Major Services in Playground
----------------------------
Expand All @@ -54,15 +51,12 @@ Major Services in Playground
* - ``Redis Commander``
- Redis web GUI.
- http://127.0.0.1:40009
* - ``Read the Docs``
- Local host docs.
- http://127.0.0.1:40010
* - ``Jupyter Lab``
- Jupyter lab with MARO environment, examples, notebooks.
- http://127.0.0.1:40011
- http://127.0.0.1:40010


*(If you use other port mapping, remember to change the port number.)*
*(Remember to change ports if you use different ports mapping.)*

Major Materials in Root Folder
------------------------------
Expand All @@ -78,4 +72,4 @@ Major Materials in Root Folder
- Quick-start tutorial.


*(Those not mentioned in the table can be ignored.)*
*(The ones not mentioned in this table can be ignored.)*
2 changes: 1 addition & 1 deletion docs/source/key_components/data_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ the backend language for improving the execution reference. What's more,
the backend store is a pluggable design, user can choose different backend
implementation based on their real performance requirement and device limitation.

Currenty there are two data model backend implementation: static and dynamic.
Currently there are two data model backend implementation: static and dynamic.
Static implementation used Numpy as its data store, do not support dynamic
attribute length, the advance of this version is that its memory size is same as its
declaration.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/scenarios/citi_bike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ too few empty docks. In such a situation, the bike repositioning is essential to
balance the bike's supply and demand. A good bike repositioning can not only meet
the needs in the stations with heavy ride demand but also free the stations that
do not have enough empty docks. Also, in the long run, a good bike repositioning
can improve the bike useability, empower citizens' daily life, and reduce the
can improve the bike usability, empower citizens' daily life, and reduce the
carbon emission.

Resource Flow
Expand Down

0 comments on commit ff0f706

Please sign in to comment.