Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web admin and process control #147

Draft
wants to merge 92 commits into
base: dev-jobqueue-old
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
d55ae9d
Test integration of Flask app into PyWPS
Jun 7, 2016
ed1dd0e
Add URL for WPS service
Jun 8, 2016
2fc0937
Changes after meeting with Jachym
Jun 8, 2016
911b3e3
Transforming server connection/Flask app with desired API, specified …
Jun 9, 2016
ca4f2db
Delete views.py file
Jun 9, 2016
518ec40
Edited URL's
Jun 16, 2016
45c735e
Working naive pause, resume, change dblog to work with postgresql
Jun 16, 2016
d8bdb75
Cosmetic updates in process control.
Jun 16, 2016
9b98fb2
Cosmetic updates in process control.
Jun 16, 2016
b08b1b8
Cosmetic alternation of server app, getting pid method
Jun 16, 2016
383eff3
Create get_process_by_uuid method and make clear code in URL handlers
Jun 17, 2016
4609265
Configuration file is loaded in ServerConnection
Jun 17, 2016
f7a058f
PostgreSQL connection is loaded from config and URL requests from Fla…
Jun 18, 2016
8a2019e
Add server/db.py, change server/wsgi, change server/app/main accorfin…
Jun 19, 2016
0852316
dblog check db according to postgresql
Jun 19, 2016
e418f1d
Added website of PyWPS Flask app with simple design and logic structu…
Jun 19, 2016
ba29736
Edited during Ubuntu setup
Jun 22, 2016
3855dc1
Updated requirements with versions od packages
Jun 22, 2016
6ec51a7
Edited requirements.txt for Ubuntu installation
Jun 22, 2016
be6e3f7
Update dblog, problem with create table
Jun 23, 2016
118f125
dblog.py missing colon
Jun 23, 2016
d5faa5c
Edited requirements.txt
Jun 24, 2016
b23ffd1
Integrate SQLAlchemy - basic
Jun 25, 2016
dd89bbb
Change of architecture, using sqlalchemy - orm
Jun 26, 2016
9871220
Create PyWPSFlask
Jun 26, 2016
f9d3fa2
Updated dblog.py, import error problem
Jun 26, 2016
e847baf
Temporary solved import error with Service in pywps_flask.py
Jun 27, 2016
80c21ef
Solved dblog.py error with ORM.
Jun 27, 2016
c2374a2
Repairing bugs in rewritten dblog.py
Jun 28, 2016
e8d54cb
Update dblog.py - error in where clause, show all processes from db
Jun 29, 2016
9734942
Cosmetic changes in dblog.py, change of views db queries and update s…
Jul 5, 2016
9a30fd6
Started adding support for control processes through the web interface
Jul 5, 2016
910c7de
Design changes of web administration
Jul 7, 2016
9ba9d1c
Pause/resume/stop in under single URL differing by HTTP
Jul 7, 2016
7d17db4
Javascript, template and view.py changes for controlling processes
Jul 8, 2016
f263bd9
Solve javascript error - no need to parse json explicitely
Jul 8, 2016
a6d8749
Solve SQLAlchemy's DatabaseError, SQLAlchemy's InvalidRequestError an…
Jul 10, 2016
659ad08
Ajax loading, template proccesses table moved to own file
Jul 10, 2016
b52bc6d
Filter in the web administration
Jul 15, 2016
50174d7
Filtering, home template, bug on WPS URL
Jul 16, 2016
ece1022
Edited docs/api.rst - resolved bug with making the documentation
Jul 18, 2016
a32e5cb
Fix UI for stopped process and JavaScript script for DELETE
Jul 18, 2016
3760f66
edited documentation
Jul 18, 2016
6e9620e
Change of the configuration loading
Jul 20, 2016
b3a3c57
Fix redundant line on import
Jul 24, 2016
88162e7
Editting the installation documentation.
Jul 24, 2016
12664cf
Work on the installation doc
Jul 24, 2016
3b22a30
Be able to run PyWPS locally with the Flask's development server
Jul 24, 2016
f31b1c6
Installation docs, english grammar mistakes
Jul 24, 2016
c0e1ecb
rewording the comment
Jul 25, 2016
47fdc02
change of identation style to spaces - IDE complaint
Jul 25, 2016
1ce0d44
add .idea files from IDE to gitignore
Jul 25, 2016
f39794f
make WPS response statuses globally available
Jul 25, 2016
61cfdbc
finishing wps_response_status being avaiable globally in constant nam…
Jul 25, 2016
928acc6
fixed jinja error, not comparing in a condition
Jul 25, 2016
618146a
forgot to rename namespace for wps response statuses in flask views
Jul 25, 2016
3a1cfef
add wps_response_status
Jul 27, 2016
c41a3a7
fix creatiation od db tables automaticly, issue of not creating db ta…
Jul 27, 2016
dec1934
alter install docs - no need to manualy create tablesa
Jul 27, 2016
b60bba4
cosmetic edit of htmll
Jul 27, 2016
5b2e271
get rid of console.log
Jul 27, 2016
97c84d5
had to edit constants from wps response
Jul 27, 2016
33e2195
wrong name for a constant
Jul 27, 2016
cb4ca49
lists processes according time_start
Jul 27, 2016
1e180a0
fix running filtering
Jul 27, 2016
375c0ae
Change /processes to /manage
Jul 31, 2016
d8a74a0
Rewrite REST API according to DRAFT
Jul 31, 2016
1915740
Refactoring the code, added missing /processes API
Aug 2, 2016
8778137
Reneming files because of naming consistency with the change in the R…
Aug 2, 2016
b9b23d4
Create db tables if dont exists
Aug 2, 2016
193b8d7
Cosmetic edits
Aug 5, 2016
99e8eb3
update docs
Aug 5, 2016
6064238
Looks tests capabilities, describe are repaired
Aug 10, 2016
5df91d7
tox tests OK with py27
Aug 12, 2016
bd9f03e
cosmetic alternation of html, css, deleting unused js files, revisite…
Aug 16, 2016
bd0e342
Fix identation, empty results
Aug 16, 2016
7e75ae5
No mixing of tabs and spaces
Aug 16, 2016
5ddd3fd
Tests for website and rest api
Aug 18, 2016
708b448
critical error fixed with returning a process instance
Aug 18, 2016
81b74a1
change alerts to console.log
Aug 18, 2016
15419cd
edited documentation about the rest api
Aug 18, 2016
40995b1
sqlalchemy session remove after a request
Aug 18, 2016
2a5e31e
temp remove of create_all
Aug 18, 2016
c7dc7cf
edited documentation
Aug 19, 2016
fb5db3a
change of creation the database tables
Aug 19, 2016
dedcd7c
fixed errors ubuntu ssl
Aug 19, 2016
cda927c
fixed ubuntu ssl error with sqlalchemy
Aug 19, 2016
545845e
note to install docs about postgresql setting
Aug 22, 2016
5ec1fe8
delete commented code
Aug 22, 2016
ab5467e
add tests to test suite
Aug 22, 2016
c12b573
add new line to meet standards
Aug 22, 2016
b91e08c
Add to tox.ini dependecies
Oct 24, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
*.pyo
*.egg-info
*.idea
dist
build
tmp
Expand Down
1 change: 1 addition & 0 deletions demo
Submodule demo added at a18a7f
2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Defining processes
Request and response objects
----------------------------

.. module:: pywps.app

.. autoclass:: WPSRequest
:members:

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Contents:
:maxdepth: 2

install
rest_api
configuration
process
exceptions
Expand Down
208 changes: 179 additions & 29 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
PyWPS-4 Installation
====================

.. note:: This installation documentation was tested on the Ubuntu 14.04 LTS operating system.

.. note:: PyWPS-4 is not tested on MS Windows platform. Please join the
development, if you need this platform to be supported. It's mainly because
Expand All @@ -11,52 +12,201 @@ PyWPS-4 Installation


Dependencies
~~~~~~~~~~~~
============

PyWPS-4 runs on Python 2.7, 3.3 or newer.
In the command line::

Prior to installing PyWPS-4, Git and the Python bindings for GDAL must be installed in the system.
In Debian based systems these packages can be installed with a tool like *apt*::
$ sudo apt-get install git python-gdal python-pip python-dev libxml2-dev libxslt1-dev zlib1g-dev libpq-dev apache2 libapache2-mod-wsgi postgresql postgresql-contrib
$ sudo pip install virtualenv

$ sudo apt-get install git python-gdal

Installation
============

PyWPS-4
~~~~~~~
A standard installation is standard Python package installation. If you want to contribute or work on PyWPS, the installation in the develop mode is also described and differs in a detail.

The easiest way to install PyWPS-4 is using the Python Package Index (PIP).
It fetches the source code from the repository and installs it automatically in the system.
This might require superuser permissions (e.g. *sudo* in Debian based systems)::
Normal installation
-------------------

$ sudo pip install -e git+https://github.com/pywps/pywps-4.git@master#egg=pywps-dev
In the command line::

In alternative PyWPS-4 can be installed manually.
It requires the cloning of the source code from the repository and then the usage of the *setup.py* script.
An example again for Debian based systems (note the usage of *sudo* for install)::
$ sudo virtualenv /var/www/gsoc-pywps-env
$ cd /var/www/gsoc-pywps-env
$ source bin/activate

$ git clone https://github.com/pywps/pywps-4.git
Change ownership and group permission according to your user account, replace the string user with your username (replace ``<user>`` with your username)::

$ cd pywps-4/
$ sudo chown -R <user>:<user> /var/www/gsoc-pywps-env

Then install deps using pip::
Clone the PyWPS and the example application into the activated virtual enviroment::

$ git clone https://github.com/jan-rudolf/pywps
$ git clone https://github.com/jan-rudolf/gsoc-pywps-app

Install Python packages and install the PyWPS::

$ cd pywps
$ pip install -r requirements.txt
$ python setup.py install

Create **/tmp/outputs** directory and change group and owner to the user that runs the application, for Apache the username and the groupname would be **www-data** by default::

$ sudo mkdir /tmp/outputs
$ sudo chown <username>:<groupname> /tmp/outputs


Develop installation
--------------------

In the command lineIn the command line::

$ sudo virtualenv /var/www/gsoc-pywps-env
$ cd /var/www/gsoc-pywps-env
$ source bin/activate

Change ownership and group permission according to your user account, replace the string user with your username (replace ``<user>`` with your username)::

$ sudo chown -R <user>:<user> /var/www/gsoc-pywps-env

Clone the PyWPS and the example application into the activated virtual enviroment::

$ git clone https://github.com/jan-rudolf/pywps
$ git clone https://github.com/jan-rudolf/gsoc-pywps-app

Install Python packages and install the PyWPS::

$ cd pywps
$ pip install -r requirements.txt
$ pip install -r requirements-dev.txt # for developer tasks
$ python setup.py develop

Create **/tmp/outputs** directory and change group and owner to the user that runs the application, for Apache the username and the groupname would be **www-data** by default::

$ sudo mkdir /tmp/outputs
$ sudo chown <username>:<groupname> /tmp/outputs


Database
========

This section describes how to setup and connect SQLite and PostgreSQL with the PyWPS.

More about how to connect other engines in the `SQLAlchemy Documentation <http://docs.sqlalchemy.org/en/latest/core/engines.html>`_.


SQLite
------

Change the **SQLAlchemyDatabaseUri** in the PyWPS configuration file under the **server** section::

SQLAlchemyDatabaseUri=sqlite:////absolute/path/to/<database_name>

Create database tables by the GET HTTP request to::

http://<URL_address>/create-database-tables


PostgreSQL
----------

System configuration
~~~~~~~~~~~~~~~~~~~~

In the command line, switch to the postgres user::

$ sudo su postgres

Create a user for the database system, fill your username::

$ createuser --pwprompt <username>

Create a database with the utf-8 encoding, fill your username from the previous step and the desired database name::

$ createdb -O<username> -Eutf-8 <database_name>

Exit the postgres's user prompt::

$ exit

Edit the table (near end of the file), that looks like the one below, so that the **METHOD** column has only **md5** entries (in case you have a different version of PostgreSQL, edit the path to the file with proper version)::

$ sudo $EDITOR /etc/postgresql/9.3/main/pg_hba.conf

+------------+------------+-----------+--------------+---------+
| TYPE | DATABASE | USER | ADDRESS | METHOD |
+============+============+===========+==============+=========+
| local | all | all | | peer |
+------------+------------+-----------+--------------+---------+
| host | all | all | 127.0.0.1/32 | md5 |
+------------+------------+-----------+--------------+---------+
| host | all | all | ::1/128 | md5 |
+------------+------------+-----------+--------------+---------+

Restart the PostgreSQL service::

$ sudo service postgresql restart


PyWPS's configuration file setting
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change the **SQLAlchemyDatabaseUri** in the PyWPS configuration file under the **server** section::

SQLAlchemyDatabaseUri=postgresql://<username>@localhost/<database_name>?sslmode=disable

*Note:* I added the parameter ``sslmode=disable``, because without it it causes error and exceptions somehow randomly. I have not figured out why.


Apache
======

In the case you want to server PyWPS on the Apache web server, here is an example of the virtual host configuration file. All paths and names are according the Installation subsection.

.. code::

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName pywps.loc
ServerAlias www.pywps.loc

ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

And install PyWPS system-wide::
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

$ sudo python setup.py install
WSGIProcessGroup pywps.loc
WSGIDaemonProcess pywps.loc processes=2 threads=15 display-name=%{GROUP}
WSGIScriptAlias / /var/www/gsoc-pywps-env/gsoc-pywps-app/wsgi.py

The demo service
~~~~~~~~~~~~~~~~
Alias "/outputs" "/tmp/outputs/"
<Directory "/tmp/outputs">
Require all granted
</Directory>

To use PyWPS-4 the user must code processes and publish them through a service.
A demo service is available that makes up a good starting point for first time users.
It can be cloned directly into the user area:
<Directory /var/www/gsoc-pywps-env/gsoc-pywps-app>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

$ git clone https://github.com/pywps/pywps-4-demo.git

It may be run right away through the *demo.py* script.
First time users should start by studying the demo project structure and then code their own processes.

Full more details please consult the :ref:`process` section.
96 changes: 96 additions & 0 deletions docs/rest_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
========
REST API
========

Processes published in PyWPS instance.

/processes
==========

Lists running processes.

+--------+-----------------------------------------+----------+--------------+------------+
| Method | Action | Format | Status Code | Returns |
+========+=========================================+==========+==============+============+
| GET | Returns a list of running processes | JSON | 200 | processes |
+--------+-----------------------------------------+----------+--------------+------------+
| POST | | | 405 | |
+--------+-----------------------------------------+----------+--------------+------------+
| PUT | | | 405 | |
+--------+-----------------------------------------+----------+--------------+------------+
| DELETE | | | 405 | |
+--------+-----------------------------------------+----------+--------------+------------+

Returns
-------

**processes**
Returns a list of running processes, every process is represented by *uuid*.


/processes/<uuid>
=================

Controls a running process.

+--------+--------------------------------------------+----------+--------------+------------+---------------------------------+
| Method | Action | Format | Status Code | Parameters | Returns |
+========+============================================+==========+==============+============+=================================+
| GET | Returns a message (description) and status | JSON | 200 | | error, message, success, status |
+--------+--------------------------------------------+----------+--------------+------------+---------------------------------+
| POST | Returns a running description and status | JSON | 405 | | error, status |
+--------+--------------------------------------------+----------+--------------+------------+---------------------------------+
| PUT | Manipulates a running process | JSON | 200 | action | error, status |
+--------+--------------------------------------------+----------+--------------+------------+---------------------------------+
| DELETE | Stop a running process | JSON | 200 | | error, status |
+--------+--------------------------------------------+----------+--------------+------------+---------------------------------+

Parameters
----------

**action**
Specifies what action would you like a process to perform.

Options:
**pause** - Pause a running process.

**resume** - Resume a paused process.

Returns
-------

**message**:
The last message/status provided by a process. These messages are designed by creators of processes scripts.

**error**:
Describes why was the request unsuccessful. The *error* field is provided only if the *status* field has a value *false*.

**success**:
Describes if the request was successful or not.

Options:
**true** - A successfully served request.

**false** - Unsuccessfully served request. An *error* message is also returned with this type of response.

**status**:
Describes what is the status of the process.

Options:
**0** - NO STATUS

**1** - STORE STATUS

**2** - STORE AND UPDATE STATUS

**3** - DONE STATUS

**4** - PAUSED STATUS

**5** - STOPPED STATUS

Example
-------

*http://localhost/wps/processes/slakdfj-234-ASDF-234* with PUT request ``{"action": "pause"}`` returns ``{"success": "true"}``

Loading