HIT2GAP-EU-PROJECT / bemserver

An open source Python server to deploy energy management solutions for buildings
http://bemserver.org
Other
37 stars 17 forks source link

Bemserver Installation #2

Open arunkollan opened 5 years ago

arunkollan commented 5 years ago

Hi pbourreau,

I thought of dockerizing BEMserver and below is my DockerCompose file which builds the BEMserver once fuseki-data and jena-fuseki containers are up. The steps are purely based on the docuen

** docker-compose **** **

version: '2.1'
services:
  bemserver:
    image: bemserver:latest
    container_name: bemserver
    build:
      dockerfile: Dockerfile
      context: .
    hostname: bemserver
    restart: always
    volumes_from:
      - fuseki-data:rw
    environment:
      - FLASK_RUN_PORT=8033
      - FLASK_ENV=development
      - LC_ALL=C.UTF-8
      - LANG=C.UTF-8
    expose:
      - "8033"
    ports:
      - "8033:8033"
    command: flask run --host=0.0.0.0
    command: bash -c "source bemserver/bin/activate  &&  flask run --host=0.0.0.0 "
  jena-fuseki:
    image: stain/jena-fuseki
    container_name: fuseki
    hostname: fuseki
    restart: always
    depends_on:
      - fuseki-data
    volumes_from:
      - fuseki-data:rw
    environment:
      - JVM_ARGS=-Xmx2048M
      - ADMIN_PASSWORD=pickasupersecurepassword
    expose:
      - "3030"
    ports:
      - "3030:3030"
  fuseki-data:
    image: busybox
    container_name: fuseki-data
    hostname: fuseki-data
    volumes:
      - fuseki-data

.**** Dockerfile ***** **

FROM ubuntu:latest
MAINTAINER fnndsc "dev@babymri.org"

RUN apt-get update \
  && apt-get install -y git \
  && apt-get install -y python3-pip python3-dev \
  && cd /usr/local/bin \
  && ln -s /usr/bin/python3 python \
  && pip3 install --upgrade pip

SHELL ["/bin/bash", "-c"]

RUN rm -rf bemserver
RUN git clone  https://github.com/HIT2GAP-EU-PROJECT/bemserver.git
WORKDIR /bemserver

RUN pip install virtualenv \
  && virtualenv bemserver

RUN apt-get install -y  aptitude wget unzip
RUN aptitude install -y  g++ make python3-dev libxmlsec1-dev
RUN source bemserver/bin/activate \
  && pip install -r requirements.txt

RUN wget https://github.com/IfcOpenShell/IfcOpenShell/releases/download/v0.5.0-preview2/ifcopenshell-python35-master-9ad68db-linux64.zip \
  && unzip ifcopenshell-python35-master-9ad68db-linux64.zip \
  && mv ifcopenshell bemserver/lib/python3.6/site-packages/

ADD https://github.com/HIT2GAP-EU-PROJECT/bemserver/blob/master/docs/deployment/data_model/bemserver_tdb.ttl fuseki-data:/fuseki/
RUN git clone https://github.com/HIT2GAP-EU-PROJECT/BEMOnt
COPY BEMOnt/models/bemont.rules fuseki:/fuseki/

I thought you might like to take a look.

Having done this .. I found the flask app does not show the index page. There are no specific templates for the application. I hope it is not deliberate

On running the flask shell I found no routers for the index.

Map([<Rule '/occupant_users/generate_account' (OPTIONS, POST) -> occupant_users.occupant_generate_account>,
 <Rule '/geographical/orientations/' (OPTIONS, HEAD, GET) -> geographical.OrientationTypes>,
 <Rule '/geographical/hemispheres/' (OPTIONS, HEAD, GET) -> geographical.HemisphereTypes>,
 <Rule '/geographical/climates/' (OPTIONS, HEAD, GET) -> geographical.ClimateTypes>,
 <Rule '/timeseries/aggregate' (OPTIONS, HEAD, GET) -> timeseries.timeseries_aggregate>,
 <Rule '/occupants/distancetopoint_types/' (OPTIONS, HEAD, GET) -> occupants.OccupantDistanceToPointType>,
 <Rule '/occupants/activity_frequencies/' (OPTIONS, HEAD, GET) -> occupants.OccupantActivityFrequency>,
 <Rule '/occupants/knowledge_levels/' (OPTIONS, HEAD, GET) -> occupants.OccupantKnowledgeLevel>,
 <Rule '/occupants/workspace_types/' (OPTIONS, HEAD, GET) -> occupants.OccupantWorkspaceType>,
 <Rule '/occupants/age_categories/' (OPTIONS, HEAD, GET) -> occupants.OccupantAgeCategory>,
 <Rule '/occupants/gender_types/' (OPTIONS, HEAD, GET) -> occupants.OccupantGenderType>,
 <Rule '/buildings/types/' (OPTIONS, HEAD, GET) -> buildings.BuildingTypes>,
 <Rule '/measures/observation_types/' (OPTIONS, HEAD, GET) -> measures.ObservationTypes>,
 <Rule '/comforts/preference_types/' (OPTIONS, HEAD, GET) -> comforts.get_occ_comfort_preference_types>,
 <Rule '/api-docs/api-docs.json' (OPTIONS, HEAD, GET) -> api-docs.openapi_json>,
 <Rule '/comforts/comfort_types/' (OPTIONS, HEAD, GET) -> comforts.get_occ_comfort_types>,
 <Rule '/measures/medium_types/' (OPTIONS, HEAD, GET) -> measures.MediumTypes>,
 <Rule '/api-docs/redoc' (OPTIONS, HEAD, GET) -> api-docs.openapi_redoc>,
 <Rule '/measures/units/' (OPTIONS, HEAD, GET) -> measures.Units>,
 <Rule '/windows/covering_types/' (OPTIONS, HEAD, GET) -> windows.WindowCoveringTypes>,
 <Rule '/outputs/timeseries/' (OPTIONS, HEAD, GET, POST) -> outputs.OutputTS>,
 <Rule '/outputs/events/' (OPTIONS, HEAD, GET, POST) -> outputs.OutputEvents>,
 <Rule '/floors/types/' (OPTIONS, HEAD, GET) -> floors.FloorTypes>,
 <Rule '/spaces/types/' (OPTIONS, HEAD, GET) -> spaces.SpaceTypes>,
 <Rule '/slabs/types/' (OPTIONS, HEAD, GET) -> slabs.SlabTypes>,
 <Rule '/buildings/' (OPTIONS, HEAD, GET, POST) -> buildings.Buildings>,
 <Rule '/occupants/' (OPTIONS, HEAD, GET, POST) -> occupants.Occupants>,
 <Rule '/measures/' (OPTIONS, HEAD, GET, POST) -> measures.Measures>,
 <Rule '/services/' (OPTIONS, HEAD, GET, POST) -> services.Services>,
 <Rule '/comforts/' (OPTIONS, HEAD, GET) -> comforts.get_occ_comforts>,
 <Rule '/comforts/' (OPTIONS, POST) -> comforts.post_occ_comforts>,
 <Rule '/facades/' (OPTIONS, HEAD, GET, POST) -> facades.Facades>,
 <Rule '/windows/' (OPTIONS, HEAD, GET, POST) -> windows.Windows>,
 <Rule '/sensors/' (OPTIONS, HEAD, GET, POST) -> sensors.Sensors>,
 <Rule '/events/' (OPTIONS, HEAD, GET, POST) -> events.Events>,
 <Rule '/floors/' (OPTIONS, HEAD, GET, POST) -> floors.Floors>,
 <Rule '/spaces/' (OPTIONS, HEAD, GET, POST) -> spaces.Spaces>,
 <Rule '/models/' (OPTIONS, HEAD, GET, POST) -> models.Models>,
 <Rule '/sites/' (OPTIONS, HEAD, GET, POST) -> sites.Sites>,
 <Rule '/zones/' (OPTIONS, HEAD, GET, POST) -> zones.Zones>,
 <Rule '/slabs/' (OPTIONS, HEAD, GET, POST) -> slabs.Slabs>,
 <Rule '/ifc/' (OPTIONS, HEAD, GET, POST) -> ifc.IFCFiles>,
 <Rule '/occupant_users/<login_id>/regenerate_pwd' (OPTIONS, POST) -> occupant_users.occupant_regenerate_pwd>,
 <Rule '/occupant_users/<login_id>/change_pwd' (OPTIONS, PUT) -> occupant_users.occupant_change_pwd>,
 <Rule '/timeseries/<timeseries_id>/resample' (OPTIONS, HEAD, GET) -> timeseries.timeseries_by_id_resample>,
 <Rule '/timeseries/<timeseries_id>/stats' (OPTIONS, HEAD, GET) -> timeseries.timeseries_by_id_stats>,
 <Rule '/outputs/timeseries/<output_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> outputs.OutputTSById>,
 <Rule '/outputs/events/<output_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> outputs.OutputEventsById>,
 <Rule '/ifc/<file_id>/import' (OPTIONS, POST) -> ifc.IFCFilesByIdImport>,
 <Rule '/timeseries/<timeseries_id>' (GET, PATCH, OPTIONS, HEAD, DELETE) -> timeseries.TimeseriesById>,
 <Rule '/buildings/<building_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> buildings.BuildingsById>,
 <Rule '/occupants/<occupancy_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> occupants.OccupantById>,
 <Rule '/measures/<measure_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> measures.MeasureById>,
 <Rule '/services/<service_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> services.ServicesById>,
 <Rule '/comforts/<comfort_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> comforts.ComfortById>,
 <Rule '/facades/<facade_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> facades.FacadesById>,
 <Rule '/windows/<window_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> windows.WindowsById>,
 <Rule '/sensors/<sensor_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> sensors.SensorById>,
 <Rule '/events/<event_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> events.EventsById>,
 <Rule '/floors/<floor_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> floors.FloorsById>,
 <Rule '/spaces/<space_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> spaces.SpacesById>,
 <Rule '/models/<model_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> models.ModelsById>,
 <Rule '/sites/<site_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> sites.SitesById>,
 <Rule '/zones/<zone_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> zones.ZonesById>,
 <Rule '/slabs/<slab_id>' (GET, OPTIONS, HEAD, DELETE, PUT) -> slabs.SlabsById>,
 <Rule '/ifc/<file_id>/<file_name>' (OPTIONS, HEAD, GET) -> ifc.IFCFilesByIdDownload>,
 <Rule '/ifc/<file_id>' (DELETE, HEAD, OPTIONS, GET) -> ifc.IFCFilesById>])

The present documentation will require updates on how the BEMserver application is installed.

xvjialing commented 5 years ago

@arunkollan do you have an bemserver docker-compose example

pbourreau commented 5 years ago

Hi @xvjialing . Just to met you know we are currently working on a docker container for BEMServer that will hopefully soon be uploaded. We will update the current issue accordingly.

arunkollan commented 5 years ago

@xvjialing @pbourreau will provide you with a version that is much complete. For the time being if you are alright with using my attempt you could try the docker archive attached. I take no responsibility. :D Archive.zip

pbourreau commented 4 years ago

Hi. just to let you know we built up some docker containers to ease the installation of BEMServer. It is made of two different containers:

eott-siz commented 3 years ago

Hi. just to let you know we built up some docker containers to ease the installation of BEMServer. It is made of two different containers:

* https://hub.docker.com/r/nbkinef4/bemserver-fuseki: to install the Jena triple store, and create a dataset with the BEMOnt schema as TBox.

* https://hub.docker.com/r/nbkinef4/bemserver: to install BEMServer on top of it.

Hello. We are very interested in these docker containers, as we are struggling to install BEMServer manually. Unfortunately we were unable to get them to work without modifications, both with the images from Docker Hub as well as as images created from the repo's Dockerfile. Most problems we encountered concerned setting files and arguments for flask and solving one problem just lead to the next. Anyway, I suppose my question is: Is there any further information on how to use the containers that is not reflected in the most recent version of INSTALL.md?

pbourreau commented 3 years ago

Hi, Thanks for your message. We also discovered some issues/bugs on the docker containers... sorry about this, we shoud remove them from the docker Hub. We are currently working on a deep refactoring of BEMServer, and therefore not working on the Docker containers of the online version. If you need assistance for a manual deployment, we can help you. Just to let you, we only tested the deployment on a Linux platform.

eott-siz commented 3 years ago

Hello and thanks for the reply. We first tried a manual installation on an Ubuntu 20.04LTS system with python 3.8. However from the Docker containers it seems the package was written specifically for python 3.4? We have not yet tried redoing the installation with python 3.4 as downgrading python on Debian/Ubuntu has proven to be a headache-inducing affair. I guess this could be part of the problems we are having?

Specifically, when installing the python depencendies via pip install -r requirements.txt (within the virtualenv), this fails because the package tables could not be installed. The pytables installation guide mentions several prerequisites, in particular HDF5 is not easily installed. We downloaded and compiled HDF5 1.8.21 and tried manually installing tables 3.5.2 setting the --hdf5 option to the HDF5 installation, but this then complained about shared libraries not being found. Installing tables 3.6.2 works, but then the package cannot even be imported, let alone used, and throws an error which appears to stem from a change in python breaking backwards compatibility. We are looking into getting a Debian or Ubuntu VM running that is using python 3.4 and will report back if that helps the issue.

Overall it's good to hear that there is further development as we are interested in building upon BEMServer, but would first need to check the project for compatibility with our plans.