Giter Site home page Giter Site logo

inasafe / inasafe-headless Goto Github PK

View Code? Open in Web Editor NEW
5.0 9.0 5.0 2.28 MB

An effort to run InaSAFE and all its functionality as a stand-alone package that is easy to install

Makefile 1.58% Shell 3.14% Python 64.25% QML 28.59% Dockerfile 2.45%
inasafe docker python qgis

inasafe-headless's Introduction

InaSAFE Headless

Run InaSAFE headlessly as docker container.

Statuses:

Build Status

codecov

Setup Development Environment

Prerequisites:

  • Running MacOS or Ubuntu 16.04/16.10
  • Docker installed
  • Ansible is installed (pip install ansible or brew install ansible)
  • PyCharm professional is installed (versions: 2016.3, 2017.1, 2017.2, or 2017.3)

Step by step

  1. Clone this repository, and open it in PyCharm.
  2. Configure specific options for your local system
    1. cd inasafe-headless/deployment/ansible/development/group_vars
    2. cp all.sample.yml all.yml
    3. Edit all.yml for this items:
      1. remote_user (your username)
      2. remote_group (your user's group) (usually your username on linux, "staff" on macos)
      3. project_path (the location of this project)
      4. interpreters->inasafe-headless->ipaddress (your IP address)
      5. test_data_path, the location of the test data within this project
  3. Go to deployment directory cd inasafe-headless/deployment
  4. Run make setup-ansible to setup the environment, make sure to get no failed. Restart PyCharm if needed.
  5. Run make build
  6. Run make up
  7. Open PyCharm preferences / options, and go to project interpreter. Make sure you have InaSAFE Headless Container as the remote python interpreter. You should make sure all python package is loaded also.
  8. If you are not in production, you need to copy/paste the file src/headless/celeryconfig_sample.py to src/headless/celeryconfig.py
  9. You should have Celery workers in Run Configurations. Check if it's running.
  10. Run unit test, to make sure all is good: make coverage-tests

Running Test

  1. In src/headless/celeryconfig.py, there is task_always_eager variable. If it's set to True, it will run the unit test synchronously. If it's set to False, it will run the unit test asynchronously.
  2. If you want to run asynchronously, you need to run Celery Worker in the Run configurations.
  3. Travis has been set to run the unit test for both synchronously and asynchronously.
  4. You can run the unit test in src/headless/tasks/test/test_celery_task.py like in the common unit test (i.e. right click and press run unittest in the test method/class).
  5. If the unit test generate a result, you can access it in the src/headless/tasks/test/data/result directory. This directory is already mounted to the container to INASAFE_OUTPUT_DIR=/home/headless/output
  6. You can delete all the result from the unit test by running make clean-test-output from the deployment directory.

Available Tasks

  1. Read metadata
    • Input: layer_uri (uri to the layer)
    • Output: Dictionary of metadata
  2. Run analysis
    • Input
      • hazard_layer_uri
      • exposure_layer_uri
      • aggregation_layer_uri
      • crs
    • Output
      output = {
          'status': 0,
          'message': '',
          'outputs': {
              'output_layer_key_1': 'output_layer_path_1',
              'output_layer_key_2': 'output_layer_path_2',
          }
      }
  3. Run multi exposure analysis
    • Input
      • hazard_layer_uri
      • exposure_layer_uri
      • aggregation_layer_uri
      • crs
    • Output
      output = {
          'status': 0,
          'message': '',
          'outputs': {
              'exposure_1': {
                  'output_layer_key_11': 'output_layer_path_11',
                  'output_layer_key_12': 'output_layer_path_12',
              },
              'exposure_2': {
                  'output_layer_key_21': 'output_layer_path_21',
                  'output_layer_key_22': 'output_layer_path_22',
              },
              'multi_exposure_output_layer_key_1':
                  'multi_exposure_output_layer_path_1',
              'multi_exposure_output_layer_key_2':
                  'multi_exposure_output_layer_path_2',
          }
      }
  4. Generate reports (with custom template)
    • Input
      • impact_layer_uri
      • custom_report_template_uri (optional)
    • Output
      output = {
          'status': 0,
          'message': '',
          'output': {
              'html_product_tag': {
                  'action-checklist-report': u'path',
                  'analysis-provenance-details-report': u'path',
                  'impact-report': u'path',
              },
              'pdf_product_tag': {
                  'action-checklist-pdf': u'path',
                  'analysis-provenance-details-report-pdf': u'path',
                  'impact-report-pdf': u'path',
                  'inasafe-map-report-landscape': u'path',
                  'inasafe-map-report-portrait': u'path',
              },
              'qpt_product_tag': {
                  'inasafe-map-report-landscape': u'path',
                  'inasafe-map-report-portrait': u'path',
              }
          },
      }
  5. Get generated reports
    • Input
      • impact_layer_uri
      • custom_report_template_uri (optional)
    • Output
      output = {
          'status': 0,
          'message': '',
          'output': {
              'html_product_tag': {
                  'action-checklist-report': u'path',
                  'analysis-provenance-details-report': u'path',
                  'impact-report': u'path',
              },
              'pdf_product_tag': {
                  'action-checklist-pdf': u'path',
                  'analysis-provenance-details-report-pdf': u'path',
                  'impact-report-pdf': u'path',
                  'inasafe-map-report-landscape': u'path',
                  'inasafe-map-report-portrait': u'path',
              },
              'qpt_product_tag': {
                  'inasafe-map-report-landscape': u'path',
                  'inasafe-map-report-portrait': u'path',
              }
          },
      }
  6. Generate contour
    1. Input: layer_uri
    2. Output: contour_uri

For more detail, please go to src/headless/tasks/inasafe_wrapper.py

inasafe-headless's People

Contributors

gustry avatar ismailsunni avatar lucernae avatar myarjunar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inasafe-headless's Issues

Enable Language Switcher

We need to support multi language report, so we need to somehow pass a parameter to specify the language in the map report

Better Setup for Testing with InaSAFE-Django

Currently, we need to tweak some parts to make inasafe-django works properly with local inasafe-headless.

  • We should make it easier by using the same path mapping in inasafe-headless.
  • We should write a README/wiki for doing this also.

Fix Portrait Map Template

The map report task is working fine for landscape template, but it's not working properly for potrait one.
To Do:

  • Add unit test for making sure that the generated map report is as expected for portrait and landscape.
  • Fix the bug

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.