added faafo example

This commit is contained in:
Sebastian Rieger
2020-04-21 15:46:58 +02:00
parent b7143441f2
commit 5b953bb5ed
38 changed files with 1851 additions and 0 deletions

17
faafo/doc/source/conf.py Normal file
View File

@ -0,0 +1,17 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
copyright = u'2015, OpenStack contributors'
master_doc = 'index'
project = u'First App Application for OpenStack'
source_suffix = '.rst'

View File

@ -0,0 +1,68 @@
Development
===========
Vagrant environment
-------------------
The `Vagrant <https://www.vagrantup.com/>`_ environment and the `Ansible <http://www.ansible.com/home>`_
playbook is used only for local tests and development of the application.
The installation of Vagrant is described at https://docs.vagrantup.com/v2/installation/index.html.
To speedup the provisioning you can install the Vagrant plugin `vagrant-cachier <https://github.com/fgrehm/vagrant-cachier>`_.
.. code::
$ vagrant plugin install vagrant-cachier
Bootstrap the Vagrant environment.
.. code::
$ vagrant up
Now it is possible to login with SSH.
.. code::
$ vagrant ssh
Open a new screen or tmux session. Aftwards run the api, worker, and producer
services in the foreground, each service in a separate window.
* :code:`faafo-api`
* :code:`faafo-worker`
* :code:`faafo-producer`
RabbitMQ server
~~~~~~~~~~~~~~~
The webinterface of the RabbitMQ server is reachable on TCP port :code:`15672`. The login is
possible with the user :code:`guest` and the password :code:`guest`.
MySQL server
~~~~~~~~~~~~
The password of the user :code:`root` is :code:`secretsecret`. The password of the user :code:`faafo`
for the database :code:`faafo` is also :code:`secretsecret`.
Virtual environment
-------------------
Create a new virtual environment, install all required dependencies and
the application itself.
.. code::
$ virtualenv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt
$ python setup.py install
Open a new screen or tmux session. Aftwards run the api and worker
services in the foreground, each service in a separate window.
.. code::
$ source .venv/bin/activate; faafo-api
$ source .venv/bin/activate; faafo-worker

View File

@ -0,0 +1,15 @@
digraph {
API -> Database [color=green];
API -> Database [color=orange];
Database -> API [color=red];
API -> Webinterface [color=red];
Producer -> API [color=orange];
Producer -> API [color=green];
Producer -> "Queue Service" [color=orange];
"Queue Service" -> Worker [color=orange];
Worker -> "Image File" [color=blue];
Worker -> "Queue Service" [color=green];
"Queue Service" -> Producer [color=green];
"Image File" -> "Storage Backend" [color=blue];
"Storage Backend" -> Webinterface [color=red];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -0,0 +1,3 @@
#!/bin/sh
dot -T png -o diagram.png diagram.dot

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

View File

@ -0,0 +1,11 @@
Implementation
==============
Frameworks
----------
* http://flask.pocoo.org/
* http://python-requests.org
* http://www.sqlalchemy.org/
* https://github.com/celery/kombu
* https://pillow.readthedocs.org/

View File

@ -0,0 +1,14 @@
First App Application for OpenStack
===================================
Contents:
.. toctree::
:maxdepth: 2
workflow
implementation
installation
usage
development
references

View File

@ -0,0 +1,8 @@
Installation
============
To install the ``First App Application for OpenStack`` run the following command.
.. code::
pip install faafo

View File

@ -0,0 +1,6 @@
References
==========
* http://en.wikipedia.org/wiki/Julia_set
* http://en.wikipedia.org/wiki/Mandelbrot_set
* http://code.activestate.com/recipes/577120-julia-fractals/

View File

@ -0,0 +1,42 @@
Usage
=====
Example image
-------------
.. image:: images/example.png
Example outputs
---------------
Producer service
~~~~~~~~~~~~~~~~
.. code::
2015-03-25 23:01:29.308 22526 INFO faafo.producer [-] generating 1 task(s)
2015-03-25 23:01:29.344 22526 INFO faafo.producer [-] generated task: {'width': 510, 'yb': 2.478654026560605, 'uuid': '212e8c23-e67f-4bd3-86e1-5a5e811ee2f4', 'iterations': 281, 'xb': 1.1428457603077387, 'xa': -3.3528957195683087, 'ya': -2.1341119130263717, 'height': 278}
2015-03-25 23:01:30.295 22526 INFO faafo.producer [-] task 212e8c23-e67f-4bd3-86e1-5a5e811ee2f4 processed: {u'duration': 0.8725259304046631, u'checksum': u'b22d975c4f9dc77df5db96ce6264a4990d865dd8f800aba2ac03a065c2f09b1e', u'uuid': u'212e8c23-e67f-4bd3-86e1-5a5e811ee2f4'}
Worker service
~~~~~~~~~~~~~~
.. code::
2015-03-25 23:01:29.378 22518 INFO faafo.worker [-] processing task 212e8c23-e67f-4bd3-86e1-5a5e811ee2f4
2015-03-25 23:01:30.251 22518 INFO faafo.worker [-] task 212e8c23-e67f-4bd3-86e1-5a5e811ee2f4 processed in 0.872526 seconds
2015-03-25 23:01:30.268 22518 INFO faafo.worker [-] saved result of task 212e8c23-e67f-4bd3-86e1-5a5e811ee2f4 to file /home/vagrant/212e8c23-e67f-4bd3-86e1-5a5e811ee2f4.png
API Service
~~~~~~~~~~~
.. code::
2015-03-25 23:01:29.342 22511 INFO werkzeug [-] 127.0.0.1 - - [25/Mar/2015 23:01:29] "POST /api/fractal HTTP/1.1" 201 -
2015-03-25 23:01:30.317 22511 INFO werkzeug [-] 127.0.0.1 - - [25/Mar/2015 23:01:30] "PUT /api/fractal/212e8c23-e67f-4bd3-86e1-5a5e811ee2f4 HTTP/1.1" 200 -
Example webinterface view
-------------------------
.. image:: images/screenshot_webinterface.png

View File

@ -0,0 +1,4 @@
Workflow
--------
.. image:: images/diagram.png