From f9d62a7ff4a68631291c2ad0b1b543bf459cf315 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Wed, 20 Sep 2023 18:28:42 +0200 Subject: [PATCH] fix docs and add docker install --- Dockerfile | 1 + assume/world.py | 2 +- compose.yml | 7 +--- docs/source/installation.rst | 81 +++++++++++++++++++++++++++++------- pyproject.toml | 7 ++-- 5 files changed, 72 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1743b55c..ea9049d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,4 +21,5 @@ RUN chown -R admin /src /home/admin USER admin RUN pip install -e . ENV PYTHONUNBUFFERED=1 +EXPOSE 9099 ENTRYPOINT ["assume"] diff --git a/assume/world.py b/assume/world.py index 68843c22..116d5822 100644 --- a/assume/world.py +++ b/assume/world.py @@ -39,7 +39,7 @@ class World: def __init__( self, - ifac_addr: str = "localhost", + ifac_addr: str = "0.0.0.0", port: int = 9099, database_uri: str = "", export_csv_path: str = "", diff --git a/compose.yml b/compose.yml index ef9cd547..87feedf6 100644 --- a/compose.yml +++ b/compose.yml @@ -60,11 +60,6 @@ services: image: ghcr.io/assume-framework/assume:latest profiles: ["cli-only"] build: . - environment: - DATABASE_URI: 'postgresql://assume:assume@assume_db/assume' - EXPORT_CSV_PATH: '' - ports: - - 5000:5000 depends_on: - assume_db - command: -s example_02 -c base -db "sqlite:///" + command: -s example_02 -db "postgresql://assume:assume@assume_db:5432/assume" diff --git a/docs/source/installation.rst b/docs/source/installation.rst index d5e05309..78fc6e56 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -2,32 +2,88 @@ Installation ################ -Getting Python +You can install ASSUME using pip or docker. Choose the appropriate +installation method based on your needs. + +Using Learning Capabilities +--------------------------- + +If you intend to use the reinforcement learning capabilities of +ASSUME and train your agents, make sure to install Torch. Detailed +installation instructions can be found `here `_. + +Using Pip/Python ============== +In general most people use an environment manager for python. +Here, Install instructions for Conda and Venv are given. + If it is your first time with Python, we recommend `conda `_ as easy-to-use package managers. It is available for Windows, Mac OS X and GNU/Linux. -Installation -============ +With Conda +---------- + +After installing conda, you can create an environment for assume like:: + + conda create -n assume python=3.11 + +accept the installed packages and activate the newly created environment:: + + conda activate assume + +Now you can proceed with the assume installation using pip below. + +With Venv +----------------- + +Venvs are the python native way of handling environments using the same python version. +To activate a venv, you have to be in the same folder where you created it. + +Using venvs, we can create a new environment:: + + python -m venv venv -You can install ASSUME using pip. Choose the appropriate -installation method based on your needs: +And activate it:: -Using pip ---------- + source venv/bin/activate + +Now you can proceed with the assume installation using pip below. + + +Install using pip +----------------- To install the core package:: pip install assume-framework +To install with learning capabilities:: + + pip install assume-framework[learning] + +To install with optimization capabilities:: + + pip install assume-framework[optimize] + To install with testing capabilities:: pip install assume-framework[test] +Install using Docker +========================================= + +After installing `Docker Engine `_ you can run:: + docker compose up -d assume_db grafana + docker compose run simulation -s example_01a -db "postgresql://assume:assume@assume_db:5432/assume" + +Now you can see the simulation results directly on grafana at `http://localhost:3000` + Timescale Database and Grafana Dashboards ------------------------------------------ +========================================= + +ASSUME supports writing into Databases supported by `SQLAlchemy `_ and CSV files. If you want to benefit from a supported database and integrated Grafana dashboards for scenario analysis, you can use the provided @@ -42,15 +98,8 @@ Follow these steps: 2. Start the database and Grafana using the following command:: - docker-compose up -d + docker compose up -d This will launch a container for TimescaleDB and Grafana with preconfigured dashboards for analysis. You can access the Grafana dashboards at `http://localhost:3000`. - -Using Learning Capabilities ---------------------------- - -If you intend to use the reinforcement learning capabilities of -ASSUME and train your agents, make sure to install Torch. Detailed -installation instructions can be found `here `_. diff --git a/pyproject.toml b/pyproject.toml index 5b9e9bbc..6ac69088 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ python-dateutil = "^2.8.2" sqlalchemy = "^2.0.9" pandas = {version = "^2.0.0"} psycopg2-binary = "^2.9.5" +pyomo = "^6.6.1" pyyaml = "^6.0" nest-asyncio = "^1.5.6" black = {version = "^23.3.0", optional = true} @@ -44,7 +45,7 @@ pytest = {version = "^7.2.2", optional = true} pytest-cov = {version = "^4.1.0", optional = true} pytest-asyncio = {version = "^0.21.1", optional = true} torch = {version = "^2.0.1", optional = true} -pyomo = {version = "^6.6.1", optional = true} + glpk = {version = "^0.4.7", optional = true} [tool.poetry.group.dev.dependencies] @@ -58,8 +59,8 @@ pytest-asyncio = "^0.21.1" [tool.poetry.extras] learning = ["torch"] -optimize = ["pyomo", "glpk"] -test = ["black", "isort", "matplotlib", "pytest", "pytest-cov", "pytest-asyncio", "pyomo", "glpk"] +optimize = ["glpk"] +test = ["black", "isort", "matplotlib", "pytest", "pytest-cov", "pytest-asyncio", "glpk"] [tool.poetry.scripts]