Skip to content

Commit

Permalink
Merge branch '14/test-suite' of https://www.github.com/thejunglejane/…
Browse files Browse the repository at this point in the history
…datums into 14/test-suite
  • Loading branch information
thejunglejane committed Jan 27, 2016
2 parents 7f404bc + 5db6c59 commit d52c76f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,26 @@ or, from Python

#### Migrating to v1.0.0

v1.0.0 introduced some changes to the database schema and the datums data model. To upgrade your existing datums database to a v1.0.0-compatible schema, a series of alembic mirations have been provided. To migrate your database
v1.0.0 introduces some changes to the database schema and the datums data model. To upgrade your existing datums database to a v1.0.0-compatible schema, a series of alembic mirations have been provided. To migrate your database, clone (or pull) this repository and run the setup script, then `cd` into the repository and run the migrations

```bash
/path/to/datums/ $ alembic upgrade head
/path/to/datums/ $ datums --update "/path/to/reporter/folder/*.json"
/path/to/datums/ $ datums --add "/path/to/reporter/folder/*.json"
```

After migrating, it's important to `--update` all reports to add the `pressure_in` and `pressure_mb` attributes on weather reports as well as the `inland_water` attribute to placemark reports. You can safely ignore the `UserWarning` that no `uniqueIdentifier` can be found for altitude reports; those altitude reports will be added when you `--add` in the next step.

v1.0.0 adds support for altitude reports. After updating, you'll need to `--add` all your reports to capture altitude reports from before May, 2015. They must be added instead of updated because altitude reports have not always had `uniqueIdentifiers`. Adding will allow datums to create UUIDs for these earlier altitude reports. If no UUID is found for an altitude report, datums canot update or delete it. See [issue 29](https://github.com/thejunglejane/datums/issues/29) for more information.

Alternatively, you could just teardown your existing datums database and setup a new one.
```bash
$ datums --teardown
$ pip install --upgrade datums
$ alembic upgrade head
$ datums --setup
$ datums --add "/path/to/reporter/folder/*.json"
```

v1.0.0 adds support for altitude reports. After `--migrate`ing, it's important to `--add` all your reports to capture these altitude reports. They must be added instead of updated because altitude reports have not always had `uniqueIdentifiers`. Adding will allow datums to create UUIDs for these altitude reports. If no UUID is found for an altitude report, datums canot update or delete it. See [issue 29](https://github.com/thejunglejane/datums/issues/29) for more information.

# Adding, Updating, and Deleting
The `pipeline` module allows you to add, update, and delete reports and questions.

Expand Down
7 changes: 6 additions & 1 deletion alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
import os


# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand Down Expand Up @@ -51,8 +53,11 @@ def run_migrations_online():
and associate a connection with the context.
"""
alembic_config = config.get_section(config.config_ini_section)
alembic_config['sqlalchemy.url'] = os.environ['DATABASE_URI']

connectable = engine_from_config(
config.get_section(config.config_ini_section),
alembic_config,
prefix='sqlalchemy.',
poolclass=pool.NullPool)

Expand Down
9 changes: 9 additions & 0 deletions datums/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,22 @@ def _report(self, action, key_mapper=mappers._report_key_mapper):
nested_levels_dict = {}
for key in _top_level:
try:
<<<<<<< HEAD
if key == 'date':
item = mappers._key_type_mapper[key](
str(self.report[key]), **{'ignoretz': True})
elif key == 'draft':
item = mappers._key_type_mapper[key](self.report[key])
else:
item = mappers._key_type_mapper[key](str(self.report[key]))
=======
if key == 'date' or key == 'timestamp':
item = mappers._key_type_mapper[key](
str(self.report[key]), **{'ignoretz': True})
else:
item = mappers._key_type_mapper[key](str(
self.report[key]) if key != 'draft' else self.report[key])
>>>>>>> 5db6c596e670f6f9d15720871ccc0ddba1edc58d
except KeyError:
item = self.report[key]
finally:
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def readme():
packages = ['datums', 'datums.pipeline', 'datums.models'],
version = __version__,
scripts = ['bin/datums'],
install_requires = ['sqlalchemy', 'sqlalchemy-utils', 'python-dateutil'],
install_requires = [
'alembic', 'sqlalchemy', 'sqlalchemy-utils', 'python-dateutil'],
tests_require = ['mock'],
description = 'A PostgreSQL pipeline for Reporter.',
author = 'Jane Stewart Adams',
author_email = '[email protected]',
Expand Down

0 comments on commit d52c76f

Please sign in to comment.