Skip to content

Commit

Permalink
Merge pull request #55 from UDST/travis-setup
Browse files Browse the repository at this point in the history
[0.1.dev18] Installation improvements and continuous integration
  • Loading branch information
smmaurer authored Nov 19, 2018
2 parents 21d2acc + fc22472 commit 11abed3
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 21 deletions.
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language: python

python:
- '2.7'
- '3.5'
- '3.6'

matrix:
include:
- python: '3.7' # temp solution until python 3.7 is more cleanly supported
dist: xenial
sudo: true
allow_failures:
- python: '3.7' # dependencies are blocking installation
fast_finish: true

install:
- pip install git+git://github.com/udst/choicemodels.git
- pip install .
- pip install -r requirements-full.txt
- pip install -r requirements-dev.txt
- pip list
- pip show urbansim_templates

script:
- cd urbansim_templates/tests
- coverage run --source urbansim_templates --module pytest --verbose

after_success:
- coverage report --show-missing
- coveralls
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Build Status](https://travis-ci.org/UDST/urbansim_templates.svg?branch=master)](https://travis-ci.org/UDST/urbansim_templates)
[![Coverage Status](https://coveralls.io/repos/github/UDST/urbansim_templates/badge.svg?branch=master)](https://coveralls.io/github/UDST/urbansim_templates?branch=master)

# UrbanSim Templates

UrbanSim Templates defines a common structure for new model steps and provides a core set of flexible templates and related tools. The goal is to enable smoother model setup, easier code reuse, and improvements to task orchestration.
Expand All @@ -9,17 +12,31 @@ UrbanSim Templates is currently in pre-release. API documentation is in the Pyth

## Installation

You can follow the setup instructions in [UAL/urbansim_parcel_bayarea](https://github.com/ual/urbansim_parcel_bayarea) to create a conda environment with everything you need for working in the UrbanSim Templates ecosystem.
It can be helpful to set up a dedicated Python environment for working on UrbanSim projects, for reproducibility and to avoid conflicts with other projects. MORE INFO TK.

### Production releases

Coming soon to pip and conda.

If you already have most of it installed, this should be sufficient:
### Development releases

The latest development release can be installed using the Github URL. These currently require having a development release of ChoiceModels as well, which you should install first.

```
pip install git+git://github.com/udst/choicemodels.git
pip install git+git://github.com/udst/urbansim_templates.git
```

### Cloning the repository

If you will be editing the library code or frequently updating to newer development versions, you can clone the repository and link it to your Python environment:

```
git clone https://github.com/udst/urbansim_templates.git
cd urbansim_templates
python setup.py develop
```


## Bug reports

Open an issue, or contact Sam (maurer@urbansim.com).
Expand Down Expand Up @@ -104,3 +121,5 @@ ModelManager works directly with the current versions of [UrbanSim](https://gith
- Shared template functionality is in `utils.py`. There's also a `TemplateStep` parent class in `shared.py`, but this hasn't worked very well; see [issue #38](https://github.com/UDST/urbansim_templates/issues/38).

- We don't have design patterns yet for templates whose final output is to _generate_ DataFrames or Series, rather than modifying existing ones, but we're working on it.

- To avoid dependency bloat, the default installation only includes the external libraries required for core model management and the most commonly used templates. Templates using additional libraries should check whether they're installed before fitting or running a model step, and provide helpful error messages if not.
5 changes: 5 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# requirements for development and testing

coverage
coveralls
pytest
3 changes: 3 additions & 0 deletions requirements-full.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# additional requirements for less-used templates

pylogit >= 0.2
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# minimal requirements for model management and core templates

choicemodels >= 0.2.dev4
numpy >= 1.14
orca >= 1.4
pandas >= 0.22
patsy >= 0.4
statsmodels >= 0.8
urbansim >= 3.1
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from setuptools import setup, find_packages

with open('requirements.txt') as f:
requirements = f.readlines()
requirements = [item.strip() for item in requirements]

setup(
name='urbansim_templates',
version='0.1.dev17',
Expand All @@ -13,14 +17,8 @@
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'License :: OSI Approved :: BSD License'
],
packages=find_packages(exclude=['*.tests']),
install_requires=[
'numpy >= 1.14',
'orca >= 1.4',
'pandana >= 0.3',
'pandas >= 0.22',
'statsmodels >= 0.8',
'urbansim >= 3.1.1'
]
)
install_requires=requirements
)
2 changes: 1 addition & 1 deletion urbansim_templates/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = __version__ = '0.1.dev17'
version = __version__ = '0.1.dev17'
29 changes: 21 additions & 8 deletions urbansim_templates/models/large_multinomial_logit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
from __future__ import print_function

import numpy as np
import pandas as pd
import patsy

import orca
from choicemodels import mnl
from choicemodels import MultinomialLogit, MultinomialLogitResults
from choicemodels.tools import (MergedChoiceTable, monte_carlo_choices,
iterative_lottery_choices)
# choicemodels imports are in the fit() and run() methods

from .. import modelmanager
from ..utils import version_greater_or_equal
from .shared import TemplateStep


Expand Down Expand Up @@ -412,6 +406,15 @@ def fit(self, mct=None):
None
"""
try:
from choicemodels import __version__, MultinomialLogit
from choicemodels.tools import MergedChoiceTable
assert version_greater_or_equal(__version__, '0.2.dev4')
except:
raise ImportError("LargeMultinomialLogitStep estimation requires "
"choicemodels 0.2.dev4 or later. For installation instructions, see "
"https://github.com/udst/choicemodels.")

if (mct is not None):
data = mct

Expand Down Expand Up @@ -476,6 +479,16 @@ def run(self, chooser_batch_size=None, interaction_terms=None):
None
"""
try:
from choicemodels import __version__, MultinomialLogitResults
from choicemodels.tools import (MergedChoiceTable, monte_carlo_choices,
iterative_lottery_choices)
assert version_greater_or_equal(__version__, '0.2.dev4')
except:
raise ImportError("LargeMultinomialLogitStep simulation requires "
"choicemodels 0.2.dev4 or later. For installation instructions, see "
"https://github.com/udst/choicemodels.")

obs = self._get_df(tables=self.out_choosers, fallback_tables=self.choosers,
filters=self.out_chooser_filters)

Expand Down
1 change: 1 addition & 0 deletions urbansim_templates/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.coverage
__pycache__/*

0 comments on commit 11abed3

Please sign in to comment.