Skip to content

Commit 11abed3

Browse files
authored
Merge pull request #55 from UDST/travis-setup
[0.1.dev18] Installation improvements and continuous integration
2 parents 21d2acc + fc22472 commit 11abed3

File tree

9 files changed

+100
-21
lines changed

9 files changed

+100
-21
lines changed

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
language: python
2+
3+
python:
4+
- '2.7'
5+
- '3.5'
6+
- '3.6'
7+
8+
matrix:
9+
include:
10+
- python: '3.7' # temp solution until python 3.7 is more cleanly supported
11+
dist: xenial
12+
sudo: true
13+
allow_failures:
14+
- python: '3.7' # dependencies are blocking installation
15+
fast_finish: true
16+
17+
install:
18+
- pip install git+git://github.com/udst/choicemodels.git
19+
- pip install .
20+
- pip install -r requirements-full.txt
21+
- pip install -r requirements-dev.txt
22+
- pip list
23+
- pip show urbansim_templates
24+
25+
script:
26+
- cd urbansim_templates/tests
27+
- coverage run --source urbansim_templates --module pytest --verbose
28+
29+
after_success:
30+
- coverage report --show-missing
31+
- coveralls

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[![Build Status](https://travis-ci.org/UDST/urbansim_templates.svg?branch=master)](https://travis-ci.org/UDST/urbansim_templates)
2+
[![Coverage Status](https://coveralls.io/repos/github/UDST/urbansim_templates/badge.svg?branch=master)](https://coveralls.io/github/UDST/urbansim_templates?branch=master)
3+
14
# UrbanSim Templates
25

36
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.
@@ -9,17 +12,31 @@ UrbanSim Templates is currently in pre-release. API documentation is in the Pyth
912

1013
## Installation
1114

12-
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.
15+
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.
16+
17+
### Production releases
18+
19+
Coming soon to pip and conda.
1320

14-
If you already have most of it installed, this should be sufficient:
21+
### Development releases
22+
23+
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.
24+
25+
```
26+
pip install git+git://github.com/udst/choicemodels.git
27+
pip install git+git://github.com/udst/urbansim_templates.git
28+
```
29+
30+
### Cloning the repository
31+
32+
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:
1533

1634
```
1735
git clone https://github.com/udst/urbansim_templates.git
1836
cd urbansim_templates
1937
python setup.py develop
2038
```
2139

22-
2340
## Bug reports
2441

2542
Open an issue, or contact Sam ([email protected]).
@@ -104,3 +121,5 @@ ModelManager works directly with the current versions of [UrbanSim](https://gith
104121
- 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).
105122

106123
- 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.
124+
125+
- 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.

requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# requirements for development and testing
2+
3+
coverage
4+
coveralls
5+
pytest

requirements-full.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# additional requirements for less-used templates
2+
3+
pylogit >= 0.2

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# minimal requirements for model management and core templates
2+
3+
choicemodels >= 0.2.dev4
4+
numpy >= 1.14
5+
orca >= 1.4
6+
pandas >= 0.22
7+
patsy >= 0.4
8+
statsmodels >= 0.8
9+
urbansim >= 3.1

setup.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from setuptools import setup, find_packages
22

3+
with open('requirements.txt') as f:
4+
requirements = f.readlines()
5+
requirements = [item.strip() for item in requirements]
6+
37
setup(
48
name='urbansim_templates',
59
version='0.1.dev17',
@@ -13,14 +17,8 @@
1317
'Programming Language :: Python :: 3',
1418
'Programming Language :: Python :: 3.5',
1519
'Programming Language :: Python :: 3.6',
20+
'License :: OSI Approved :: BSD License'
1621
],
1722
packages=find_packages(exclude=['*.tests']),
18-
install_requires=[
19-
'numpy >= 1.14',
20-
'orca >= 1.4',
21-
'pandana >= 0.3',
22-
'pandas >= 0.22',
23-
'statsmodels >= 0.8',
24-
'urbansim >= 3.1.1'
25-
]
26-
)
23+
install_requires=requirements
24+
)

urbansim_templates/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = __version__ = '0.1.dev17'
1+
version = __version__ = '0.1.dev17'

urbansim_templates/models/large_multinomial_logit.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
from __future__ import print_function
22

3-
import numpy as np
4-
import pandas as pd
5-
import patsy
6-
73
import orca
8-
from choicemodels import mnl
9-
from choicemodels import MultinomialLogit, MultinomialLogitResults
10-
from choicemodels.tools import (MergedChoiceTable, monte_carlo_choices,
11-
iterative_lottery_choices)
4+
# choicemodels imports are in the fit() and run() methods
125

136
from .. import modelmanager
7+
from ..utils import version_greater_or_equal
148
from .shared import TemplateStep
159

1610

@@ -412,6 +406,15 @@ def fit(self, mct=None):
412406
None
413407
414408
"""
409+
try:
410+
from choicemodels import __version__, MultinomialLogit
411+
from choicemodels.tools import MergedChoiceTable
412+
assert version_greater_or_equal(__version__, '0.2.dev4')
413+
except:
414+
raise ImportError("LargeMultinomialLogitStep estimation requires "
415+
"choicemodels 0.2.dev4 or later. For installation instructions, see "
416+
"https://github.com/udst/choicemodels.")
417+
415418
if (mct is not None):
416419
data = mct
417420

@@ -476,6 +479,16 @@ def run(self, chooser_batch_size=None, interaction_terms=None):
476479
None
477480
478481
"""
482+
try:
483+
from choicemodels import __version__, MultinomialLogitResults
484+
from choicemodels.tools import (MergedChoiceTable, monte_carlo_choices,
485+
iterative_lottery_choices)
486+
assert version_greater_or_equal(__version__, '0.2.dev4')
487+
except:
488+
raise ImportError("LargeMultinomialLogitStep simulation requires "
489+
"choicemodels 0.2.dev4 or later. For installation instructions, see "
490+
"https://github.com/udst/choicemodels.")
491+
479492
obs = self._get_df(tables=self.out_choosers, fallback_tables=self.choosers,
480493
filters=self.out_chooser_filters)
481494

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
.coverage
12
__pycache__/*

0 commit comments

Comments
 (0)