Skip to content

Commit

Permalink
Use singleton-like Meta class to store global state
Browse files Browse the repository at this point in the history
Merge Pull Request #36. Closes #34.
  • Loading branch information
lukehsiao authored Mar 30, 2018
2 parents f2a8e7c + c21d439 commit 793df54
Show file tree
Hide file tree
Showing 25 changed files with 636 additions and 445 deletions.
29 changes: 28 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,37 @@
Fonduer is still under active development and APIs may still change
rapidly.

Version 0.1.5
-------------
.. warning::
This release is NOT backwards compatable with v0.1.4. Specifically, in order
to initialize a session with postgresql, you no longer do

.. code:: python
os.environ['SNORKELDB'] = 'postgres://localhost:5432/' + DBNAME
from fonduer import SnorkelSession
session = SnorkelSession()
which had the side-effects of manipulating your database tables on import
(or creating a ``snorkel.db`` file if you forgot to set the environment
variable). Now, you use the Meta class to initialize your session:

.. code:: python
from fonduer import Meta
session = Meta.init("postgres://localhost:5432/" + DBNAME).Session()
No side-effects occur until ``Meta`` is initialized.

* `@lukehsiao`_: Remove reliance on environment vars and remove side-effects of
importing fonduer (`#36 <https://github.com/HazyResearch/fonduer/pull/36>`_)

Version 0.1.4
-------------

* `@lukehsiao`_: Separate tutorials into their own repo (`#31 <https://github.com/HazyResearch/fonduer/pull/31>`_)
* `@lukehsiao`_: Separate tutorials into their own repo (`#31
<https://github.com/HazyResearch/fonduer/pull/31>`_)

Version 0.1.3
-------------
Expand Down
54 changes: 8 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Fonduer

[![Travis](https://img.shields.io/travis/HazyResearch/fonduer.svg)](https://travis-ci.org/HazyResearch/fonduer)
[![Coveralls github](https://img.shields.io/coveralls/github/HazyResearch/fonduer.svg)](https://coveralls.io/github/HazyResearch/fonduer)
[![Read the Docs](https://img.shields.io/readthedocs/fonduer.svg)](https://fonduer.readthedocs.io/)
[![GitHub license](https://img.shields.io/github/license/HazyResearch/fonduer.svg)](https://github.com/HazyResearch/fonduer/blob/master/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/HazyResearch/fonduer.svg)](https://github.com/HazyResearch/fonduer/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/HazyResearch/fonduer.svg)](https://github.com/HazyResearch/fonduer/issues)
[![PyPI](https://img.shields.io/pypi/v/fonduer.svg)](https://pypi.org/project/fonduer/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fonduer.svg)](https://pypi.org/project/fonduer/)
[![GitHub issues](https://img.shields.io/github/issues/HazyResearch/fonduer.svg)](https://github.com/HazyResearch/fonduer/issues)
[![Travis](https://img.shields.io/travis/HazyResearch/fonduer.svg)](https://travis-ci.org/HazyResearch/fonduer)
[![Coveralls github](https://img.shields.io/coveralls/github/HazyResearch/fonduer.svg)](https://coveralls.io/github/HazyResearch/fonduer)
[![GitHub stars](https://img.shields.io/github/stars/HazyResearch/fonduer.svg)](https://github.com/HazyResearch/fonduer/stargazers)
[![GitHub license](https://img.shields.io/github/license/HazyResearch/fonduer.svg)](https://github.com/HazyResearch/fonduer/blob/master/LICENSE)

`Fonduer` is a framework for building knowledge base construction (KBC)
applications from _richy formatted data_ and is implemented as a library on
Expand All @@ -33,47 +33,9 @@ to submit your contributions as a pull request._

## Installation

### Dependencies

We use a few applications that you'll need to install and be sure are on your
PATH.

For OS X using [homebrew](https://brew.sh):

```bash
brew install poppler
brew install postgresql
```

On Debian-based distros:

```bash
sudo apt-get install poppler-utils
sudo apt-get install postgresql
```

For the Python dependencies, we recommend using a
[virtualenv](https://virtualenv.pypa.io/en/stable/). Once you have cloned the
repository, change directories to the root of the repository and run

```bash
virtualenv -p python3 .venv
```

Once the virtual environment is created, activate it by running

```bash
source .venv/bin/activate
```

Any Python libraries installed will now be contained within this virtual
environment. To deactivate the environment, simply run `deactivate`.

Then, install `Fonduer` by running

```bash
pip install fonduer
```
Check out our [Getting Started
Guide](https://fonduer.readthedocs.io/en/latest/user/getting_started.html) to
get up and running.

## Learning how to use `Fonduer`

Expand Down
27 changes: 1 addition & 26 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,18 @@
import sys
sys.path.insert(0, os.path.abspath('..'))

# Mock imports for troublesome modules (i.e. any that use C code)
# See: http://blog.rtwilson.com/how-to-make-your-sphinx-documentation-compile-with-readthedocs-when-youre-using-numpy-and-scipy/
import mock
MOCK_MODULES = [
autodoc_mock_imports = [
'future',
'matplotlib',
'matplotlib.pyplot',
'nltk',
'nltk.stem.porter',
'np',
'numba',
'numbskull',
'numbskull.inference',
'numbskull.numbskulltypes',
'numpy',
'pandas',
'plt',
'scipy',
'scipy.sparse',
'spacy',
'spacy.cli',
'spacy.deprecated',
'sparse',
'sparse.csr_matrix',
'sqlalchemy',
'sqlalchemy.dialects',
'sqlalchemy.engine',
'sqlalchemy.ext',
'sqlalchemy.ext.declarative',
'sqlalchemy.orm',
'sqlalchemy.sql',
'sqlalchemy.types',
'tensorflow',
'tensorflow.contrib.rnn',
]
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.MagicMock()

# -- Project information -----------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion docs/dev/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ Changelog
=========

.. include:: ../../CHANGELOG.rst

1 change: 0 additions & 1 deletion docs/dev/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ locally.
make test
.. _pytest: https://docs.pytest.org/en/latest/
.. _installing: install.html
26 changes: 12 additions & 14 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@ submit your contributions as a pull request.
.. _Issues: https://github.com/hazyresearch/fonduer/issues

.. toctree::
:maxdepth: 2
:caption: User Documentation

user/lf_helpers
user/faqs

:maxdepth: 2
:caption: User Documentation

.. toctree::
:maxdepth: 2
:caption: Developer Documentation

dev/changelog
dev/install
dev/tests
user/getting_started
user/lf_helpers
user/faqs

.. toctree::
:maxdepth: 2
:caption: Developer Documentation

dev/changelog
dev/install
dev/tests

Acknowledgements
----------------
Expand All @@ -53,4 +52,3 @@ findings, and conclusions or recommendations expressed in this material are
those of the authors and do not necessarily reflect the views, policies, or
endorsements, either expressed or implied, of DARPA, DOE, NIH, ONR, or the U.S.
Government.

1 change: 0 additions & 1 deletion docs/user/faqs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ testing on 14.04 or older.

.. _see changelog: https://poppler.freedesktop.org/releases.html
.. _install manually: https://poppler.freedesktop.org

64 changes: 64 additions & 0 deletions docs/user/getting_started.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Getting Started
===============

This document will show you how to get up and running with Fonduer. We'll show
you how to get everything installed and your machine so that you can walk
through real examples by checking out our Tutorials_.

Installing External Dependencies
--------------------------------

Fonduer relies on a couple of external applications. You'll need to install
these and be sure are on your ``PATH``.

For OS X using homebrew_::

$ brew install poppler
$ brew install postgresql

On Debian-based distros::

$ sudo apt update
$ sudo apt install poppler-utils
$ sudo apt install postgresql

.. note::
Fonduer requires PostgreSQL version 9.6 or above.

.. note::
Fonduer requires ``poppler-utils`` to be version 0.36.0 or above.
Otherwise, the ``-bbox-layout`` option is not available for ``pdftotext``
(`see changelog`_).

Installing the Fonduer Package
------------------------------

Then, install Fonduer by running::

$ pip install fonduer

.. note::
Fonduer only supports Python 3. Python 2 is not supported.

.. tip::
For the Python dependencies, we recommend using a virtualenv_, which will
allow you to install Fonduer and it's python dependencies in a isolated
Python environment. Once you have virtualenv installed, you can create a
Python 3 virtual environment as follows.::

$ virtualenv -p python3 .venv

Once the virtual environment is created, activate it by running::

$ source .venv/bin/activate

Any Python libraries installed will now be contained within this virtual
environment. To deactivate the environment, simply run::
$ deactivate


.. _Tutorials: https://github.com/HazyResearch/fonduer-tutorials
.. _homebrew: https://brew.sh
.. _virtualenv: https://virtualenv.pypa.io/en/stable/
.. _see changelog: https://poppler.freedesktop.org/releases.html
1 change: 0 additions & 1 deletion docs/user/lf_helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ and visual information.
.. automodule:: fonduer.lf_helpers
:members:


.. _Fonduer: https://github.com/HazyResearch/fonduer
2 changes: 1 addition & 1 deletion fonduer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fonduer.async_annotations import BatchLabelAnnotator
from fonduer.candidates import CandidateExtractor, OmniNgrams, OmniFigures
from fonduer.matchers import LambdaFunctionFigureMatcher
from fonduer.models import (SnorkelSession, Document, Phrase, Figure,
from fonduer.models import (Meta, Document, Phrase, Figure,
candidate_subclass)
from fonduer.parser import HTMLPreprocessor
from fonduer.parser import OmniParser
Expand Down
2 changes: 1 addition & 1 deletion fonduer/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.4"
__version__ = "0.1.5"
Loading

0 comments on commit 793df54

Please sign in to comment.