Skip to content

Commit

Permalink
Merge branch 'master' into consequential
Browse files Browse the repository at this point in the history
# Conflicts:
#	ocelot/configuration.py
#	ocelot/errors.py
#	ocelot/model.py
#	ocelot/transformations/locations/markets.py
#	tests/locations/markets.py
  • Loading branch information
cmutel committed May 4, 2017
2 parents 3b8c4dd + fbb956d commit cb93104
Show file tree
Hide file tree
Showing 80 changed files with 49,204 additions and 47,450 deletions.
12 changes: 7 additions & 5 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
Copyright (c) 2016, Paul Scherrer Institut and ecoinvent centre
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided
with the distribution.
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

Neither the name of Paul Scherrer Institut or the ecoinvent centre nor the
names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down
31 changes: 18 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
# Modified from https://ci.appveyor.com/project/jkbrzt/httpie
skip_commits:
message: /^Merge pull request /

build: false

environment:
PYTHONIOENCODING: "UTF-8"

matrix:
- PYTHON: "C:\\Python35_64"
PYTHON_VERSION: "3.5"
PYTHON_ARCH: "64"
- PYTHON_VERSION: "3.5"
PYTHON_ARCH: "32"
CONDA_PY: "35"
CONDA_NPY: "110"
CONDA_INSTALL_LOCN: "C:\\Miniconda35"

- PYTHON: "C:\\Python35_32"
PYTHON_VERSION: "3.5"
PYTHON_ARCH: "32"
- PYTHON_VERSION: "3.5"
PYTHON_ARCH: "64"
CONDA_PY: "35"
CONDA_NPY: "110"
CONDA_INSTALL_LOCN: "C:\\Miniconda35-x64"

install:
- powershell .\\ci\\appveyor-install.ps1
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "pip install --no-cache-dir -r requirements.txt"
# Use the pre-installed Miniconda for the desired arch
- cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat
- cmd: conda update -y -q conda
- cmd: conda install -y -q -c cmutel -c conda-forge bw2parameters
- cmd: conda install -y -q -c conda-forge numpy scipy psutil bw2parameters appdirs arrow docopt docutils jinja2 lxml pandas pyprind pytest cytoolz wrapt voluptuous
- cmd: pip install stats_arrays

test_script:
- "py.test"
- pytest
- "python setup.py -q install"
- "python.exe tests/manual/run_all_ci.py"
96 changes: 0 additions & 96 deletions ci/appveyor-install.ps1

This file was deleted.

1 change: 0 additions & 1 deletion ci/requirements-travis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ numpy
pandas
psutil
pyprind
pyrsistent
pytest
pytest-cov
python-coveralls
Expand Down
151 changes: 0 additions & 151 deletions docs/cutoff.rst.orig

This file was deleted.

44 changes: 8 additions & 36 deletions docs/foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,57 +42,29 @@ The ``system_model`` function is actually quite simple:
Transformation functions
========================

Transform functions are the heart of Ocelot - each one performs one distinct change to the collection of datasets. Transform functions can be any callable, bit are mostly commonly functions.
.. note:: See also :ref:`writing`.

The report generator will use information about each transform function when creating the report. Specifically, the report generator will look at the function name, its `docstring <https://www.python.org/dev/peps/pep-0257/>`__ (a text description of what the function does, included in the function code), and a new object attribute that you have to specify: ``__table__``.
Transform functions are the heart of Ocelot - each one performs one distinct change to the collection of datasets. Transform functions can be any callable, but most are simple functions.

Most of the time you will want to provide logging data that will be turned into tables in the run report. To do this, define the transformation function attribute ``__table__`` as follows:

.. code-block:: python
def some_transformation(data):
return data
some_transformation.__table__ = {
'title': 'Name of title to put in report',
'columns': ["names", "of", "columns"]
}
Functions take two input arguments: The input ``data``, and the ``logger``. Functions should return the transformed data. Log messages are written using ``logger.log(message)``. Log messages should be a dictionary, with at least the key ``type`` defined. Log messages that provide table data should look like this:

.. code-block:: python
logger.log({
'type': 'table element',
'data': [data in same order as columns]
})
Log messages that provide data in a list format look like this:

.. code-block:: python
logger.log({
'type': 'list element',
'data': HTML string
})
If you need to initialize functions using `functools.partial <https://docs.python.org/3.5/library/functools.html#functools.partial>`__, the report generator will still get the correct function metadata. Other forms of currying are not supported.
The report generator will use information about each transformation function when creating the report. Specifically, the report generator will look at the function name, its `docstring <https://www.python.org/dev/peps/pep-0257/>`__ (a text description of what the function does, included in the function code), and any additional tabular data your provide during the function call.

.. _logger:

Logging
=======

Ocelot uses standard `python logging <https://docs.python.org/3/library/logging.html>`_, with a custom formatter that encodes log messages to JSON dictionaries. Therefore, log messages must be **dictionaries**:
Ocelot uses standard `python logging <https://docs.python.org/3/library/logging.html>`__, with a custom formatter that encodes log messages to JSON dictionaries. Due to this custom formatter, the ``ocelot`` logger must be retrieved in each file which uses logging:

.. code-block:: python
import logging
logger = logging.getLogger('ocelot')
def my_transformation(data):
logging.info({"message": "something", "count": len(data)})
logger.info({"message": "something", "count": len(data)})
Log messages are written when a run is started or finished, when transformation functions are started or finished, and whenever the transformation function wants to log something. The log message format is documented in :ref:`logging-format`.
Log messages are written when a run is started or finished, when transformation functions are started or finished, and whenever the transformation function wants to log something. The message format for the log written to disk (i.e. with each line JSON encoded) is documented in :ref:`logging-format`.

.. note:: ``time`` is added automatically to each log message.

Expand Down
Binary file added docs/images/code-as-logo-full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/code-as-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cb93104

Please sign in to comment.