Skip to content

Commit

Permalink
Merge pull request #139 from jeremycline/documentation
Browse files Browse the repository at this point in the history
Add a Sphinx documentation project
  • Loading branch information
jeremycline committed Dec 19, 2016
2 parents d788b54 + 0f3150e commit 69a1973
Show file tree
Hide file tree
Showing 19 changed files with 1,465 additions and 259 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ build
*.pyc
*.egg*

# Ignore the repos checked out within this repo
fmn.web
fmn.sse

# Images are generated as part of the docs build process
docs/images/*

.dnf-cache/
.vagrant/
Vagrantfile
*.retry
fmn.sse
fmn.web
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sudo: required
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
Expand All @@ -12,9 +11,10 @@ install:
- pip install --upgrade setuptools pip
- pip install -r tests-requirements.txt
- pip install -e .
script: python setup.py test
script: python -m unittest discover

matrix:
allow_failures:
- python: "3.3"
- python: "2.6"
- python: "3.4"
- python: "3.5"
192 changes: 16 additions & 176 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,187 +1,27 @@
Fedora Notifications
FedMSG Notifications
====================

``fmn`` is a family of systems to manage end-user
notifications triggered by `fedmsg, the Fedora FEDerated MESsage bus
<http://fedmsg.com>`_.
``fmn`` is a family of systems to manage end-user notifications triggered by
`fedmsg, the FEDerated MESsage bus <http://fedmsg.com>`_. ``fmn`` provides a
single place for all applications using ``fedmsg`` to notify users of events.
Notifications can be delivered by email, irc, and server-sent events. Users
can configure their notifications for all the applications they use in one
place.

The "wins" here are:
FMN is deployed in `Fedora <https://apps.fedoraproject.org/notifications/>`_.

- A single place for email code to live, instead of being duplicated in
every application that we write and deploy. This will ostensibly reduce
the amount of code we have to maintain.
- Diverse kinds of notifications. Some users don't want email.
- A single place for end-users to manage notification preferences.
Instead of having to tweak preferences in bodhi, koji, pkgdb, etc..
they can choose what they do and don't want to receive at
(hypothetically) https://apps.fedoraproject.org/notifications/

We would like to be able to serve notifications via these means,
listed in order by priority:
Documentation
-------------

- Email.
- IRC private messages directed at users.
- Desktop popups.
- Android notifications via Google Cloud Messaging.
- Websocket notifications on webapps.
- User-specific RSS feeds
Documentation is available in the docs/ directory or `online <https://fedora-infra.github.io/fmn/>`_

For terminology's sake, refer to these as the ``N`` notification ``contexts``.
You need sphinx, sqlalchemy_schemadisplay, and graphviz to build the
documentation.

Hacking
-------

*This repository is just a placeholder* and the code for the various
components can be found here:

- `fmn.rules <https://github.com/fedora-infra/fmn.rules>`_
- `fmn.lib <https://github.com/fedora-infra/fmn.lib>`_
- `fmn.consumer <https://github.com/fedora-infra/fmn.consumer>`_
- `fmn.web <https://github.com/fedora-infra/fmn.web>`_
- `fmn.sse <https://github.com/fedora-infra/fmn.sse>`_


Vagrant
^^^^^^^

A Vagrantfile is provided as ``Vagrantfile.example``. You can get started by
installing Vagrant and starting your own ``Vagrantfile`` from the example::

$ sudo dnf install ansible vagrant-libvirt vagrant-sshfs
$ cp Vagrantfile.example Vagrantfile
$ vagrant up

There are several configurations in the Vagrantfile you may want to alter.
documentation can be found inline. Note that performing ``vagrant up`` will
check out ``fmn.rules``, ``fmn.lib``, ``fmn.consumer``, ``fmn.web``, and
``fmn.sse`` out in the root of the ``fmn`` repository if you haven't already
done so.


Manual
^^^^^^

If you want to set up fmn for development, you could try something like this:

- Set up a virtualenv:

- ``$ mkvirtualenv fmn``

- Install all the subcomponents, in order, as development deps:

- ``$ for i in rules lib consumer web; do git clone git@github.com:fedora-infra/fmn.$i.git; done``
- ``$ for i in rules lib consumer web; do pushd fmn.$i; python setup.py develop; popd; done``

- Do the base libs tests pass?

- ``$ pushd fmn.lib; python setup.py test; popd``

- Create some dev data for the webapp:

- ``$ pushd fmn.web; python ../fmn.lib/createdb.py --with-dev-data; popd``

- Start the webapp:

- ``$ pushd fmn.web; python fmn/web/main.py; popd``

- Run the consumer to give it a try:

- ``$ pushd fmn.consumer; fedmsg-hub; popd``


Architecture
Contributing
------------

::

| +--------\
| read | prefs | write
| +---->| DB |<--------+
| | \--------+ |
| +-----+---+---+ +---+---+---+---+ +----+
| | |fmn.lib| | |fmn.lib| | |user|
v | +-------+ | +-------+ | +--+-+
fedmsg+->|consumer | |central webapp |<-----+
+ +-----+ +---+| +---------------+
| |email| |irc||
| +-+---+--+-+-++
| | |
| | |
v v v

For each user, the central data store will keep ``N`` distinct profiles,
one for each notification ``context``.

Specification of a Profile
--------------------------

Here's a proposal:

A user's account has a series of messaging contexts. A messaging context is
one of 'Email', 'IRC', 'Android', etc..

For each context, a user has an unlimited number of filters.

Each filter has an unlimited number of rules.

A rule is something like: "is a bodhi message" or "pertains to a package
owned by me." They will be implemented as python functions. The database model
will refer to them in some form like ``fmn.rules:pertains_to_me`` or
``fmn.rules:is_a_bodhi_message``. They can optionally take arguments, which
will be tricky. For instance, ``fmn.rules:pertains_to_a_package_owned_by``
needs a username for it to make any sense.

::

User ---+-------------------------+------------------+
| | |
V V V
Email IRC Android
| | |
+--->Filter1 +--->Filter1 +----->Filter1
| | | |
| +-> is a koji build +-> pertains to a +-> pertains
| | completed message package owned to the
| | by me package
| +-> pertains to a package 'nethack'
| | owned by me
| |
| +-> does not pertain to
| package 'nethack'
|
+--->Filter2
|
+-> is a bodhi message
|
+-> pertains to a package
owned by 'lmacken'

If *all* the rules match for *any* filter in a given context, a notification
is deployed for that context. In other words, the filters are OR'd together
and the rules that make up a filter are AND'd together. If multiple contexts
have a filter that succeeds, notifications are deployed for all of those
contexts.

Context-specific Delivery Metadata
----------------------------------

- context-specific delivery data?

- For instance, my FAS username is ralph but
my irc nick is threebean. How will the irc daemon find that out? Do we
store it in the notif profile? Or does the irc daemon query FAS? If we
store it in the notif profile, then it is public. The data store is world
readable.

- The android notifications need a "device id" tied to each user. Can this
be public?

Future Features
---------------

Things that we would like to have, but don't necessarily need to be in a first
release can be listed here.

- Templates for new users. Packagers should start with a "packager"
profile for their email context. You should be able to "clone" one of your
context from one of a few existing templates.
Consult the `contribution guide <https://fedora-infra.github.io/fmn/contributing.html>`_
in our documentation!
36 changes: 0 additions & 36 deletions RULES.rst

This file was deleted.

46 changes: 42 additions & 4 deletions ansible/roles/fmn-dev/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
dnf: name={{ item }} state=present
with_items:
- git
- python-sphinx
- python-virtualenvwrapper
- vim-enhanced

Expand All @@ -22,7 +21,9 @@
dnf: name={{ item }} state=present
with_items:
- gcc
- graphviz
- libffi-devel
- make
- openssl-devel
- python2-devel
- python3-devel
Expand All @@ -40,15 +41,21 @@
- name: Install the message of the day
copy: src=motd dest=/etc/motd

- name: Create fmn virtualenv
- name: Create python2-fmn virtualenv
become_user: "{{ ansible_env.SUDO_USER }}"
shell: "source ~/.bashrc && mkvirtualenv python2-fmn"
args:
creates: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/python2-fmn

- name: Create python3-fmn virtualenv
become_user: "{{ ansible_env.SUDO_USER }}"
shell: "source ~/.bashrc && mkvirtualenv --python=python3 python3-fmn"
args:
creates: /home/{{ ansible_env.SUDO_USER }}/.virtualenvs/python3-fmn

# For some reason, doing ``python setup.py develop`` fails to install
# Flask, whereas doing it with pip works fine
- name: Install Python runtime requirements
- name: Install Python 2 runtime requirements
become_user: "{{ ansible_env.SUDO_USER }}"
pip:
requirements: "{{ item }}/requirements.txt"
Expand All @@ -61,6 +68,17 @@
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

# Ansible with Pip and Python 3 seems to try to install to the global site-packages
# NOTE: Sadly fmn.web isn't Python 3 compatible yet
- name: Install Python 3 runtime requirements
become_user: "{{ ansible_env.SUDO_USER }}"
shell: "source ~/.bashrc && workon python3-fmn && pip install -r {{ item }}/requirements.txt"
with_items:
- "."
- "fmn.sse"
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

- name: Install Python 2 tests requirements
become_user: "{{ ansible_env.SUDO_USER }}"
pip:
Expand All @@ -74,7 +92,21 @@
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

- name: Install fmn packages
# NOTE: Sadly fmn.web isn't Python 3 compatible yet
- name: Install Python 3 tests requirements
become_user: "{{ ansible_env.SUDO_USER }}"
shell: "source ~/.bashrc && workon python3-fmn && pip install -r {{ item }}/tests-requirements.txt"
with_items:
- "."
- "fmn.sse"
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

- name: Install packages necessary to build the documentation
become_user: "{{ ansible_env.SUDO_USER }}"
shell: "source ~/.bashrc && workon python3-fmn && pip install sphinx sqlalchemy_schemadisplay"

- name: Install fmn packages into the Python 2 virtualenv
become_user: "{{ ansible_env.SUDO_USER }}"
shell: "pushd {{ item }} && source ~/.bashrc && workon python2-fmn && python setup.py develop && popd"
with_items:
Expand All @@ -84,6 +116,12 @@
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

- name: Install fmn packages into the Python 3 virtualenv
become_user: "{{ ansible_env.SUDO_USER }}"
shell: "source ~/.bashrc && workon python3-fmn && pip install -e ."
args:
chdir: /home/{{ ansible_env.SUDO_USER }}/devel

- name: Enable the RabbitMQ management console
command: rabbitmq-plugins enable rabbitmq_management

Expand Down
Binary file removed database.png
Binary file not shown.

0 comments on commit 69a1973

Please sign in to comment.