From 457ce95de6b81cdb1d1f9298b71a6678955f2e61 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Tue, 6 Nov 2018 15:20:25 -0800 Subject: [PATCH 01/18] Travis script --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f2a94c4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: python + +python: + - '3.6' + +install: + - pip install . + - pip show urbansim_templates + +script: + - cd urbansim_templates/tests + - pytest *.pytest + +after_success: + - coverage report -m \ No newline at end of file From b8321527f90c0f15a0701f639bed81788958aeac Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Tue, 6 Nov 2018 15:25:17 -0800 Subject: [PATCH 02/18] Python 2.7 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f2a94c4..b40e3bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: + - '2.7' - '3.6' install: From c815e640b5374d341309914426a5534698bdf6fd Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Tue, 6 Nov 2018 16:52:27 -0800 Subject: [PATCH 03/18] Test syntax --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b40e3bc..269b5d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ install: script: - cd urbansim_templates/tests - - pytest *.pytest + - pytest *.py after_success: - coverage report -m \ No newline at end of file From da10f4dc3b7120a8c8e714fa701d81264a17b579 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Tue, 6 Nov 2018 17:03:35 -0800 Subject: [PATCH 04/18] Pip install choicemodels --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 269b5d1..61da70c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ python: install: - pip install . + - pip install git+git://github.com/udst/choicemodels.git + - pip list - pip show urbansim_templates script: From 2af792b09970daf26fe9d1ffef4cbf6cbf3953a9 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 13:13:48 -0800 Subject: [PATCH 05/18] Version checks for choicemodels --- setup.py | 6 ++-- .../models/large_multinomial_logit.py | 29 ++++++++++++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 03c14be..0a3b2a6 100644 --- a/setup.py +++ b/setup.py @@ -16,11 +16,11 @@ ], packages=find_packages(exclude=['*.tests']), install_requires=[ + 'choicemodels >= 0.2.dev4', 'numpy >= 1.14', 'orca >= 1.4', - 'pandana >= 0.3', 'pandas >= 0.22', - 'statsmodels >= 0.8', - 'urbansim >= 3.1.1' + 'statsmodels >= 0.9', + 'urbansim >= 3.1' ] ) diff --git a/urbansim_templates/models/large_multinomial_logit.py b/urbansim_templates/models/large_multinomial_logit.py index 3af0d78..1f4d978 100644 --- a/urbansim_templates/models/large_multinomial_logit.py +++ b/urbansim_templates/models/large_multinomial_logit.py @@ -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 @@ -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 @@ -455,6 +458,16 @@ def run(self): as well ('probabilities'). """ + 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) From bb0de4392e44b2ea22eeda3c60a0dbf9c1bd824b Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 13:31:11 -0800 Subject: [PATCH 06/18] Update README.md --- README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dbfea42..3cf1389 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,24 @@ 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. -If you already have most of it installed, this should be sufficient: +### Production releases + +Coming soon to pip and conda. + +### 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 @@ -19,7 +34,6 @@ cd urbansim_templates python setup.py develop ``` - ## Bug reports Open an issue, or contact Sam (maurer@urbansim.com). @@ -104,3 +118,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. From c018fabe1d1735890b30fb4a0b965f8f77aa7cea Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 13:32:26 -0800 Subject: [PATCH 07/18] Install choicemodels first --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 61da70c..c76872d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,12 @@ language: python python: - '2.7' + - '3.5' - '3.6' install: - - pip install . - pip install git+git://github.com/udst/choicemodels.git + - pip install . - pip list - pip show urbansim_templates From e6e4625ac53d61e7f9dc2131979cbc325f85c48e Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 13:52:32 -0800 Subject: [PATCH 08/18] Moving requirements to separate files --- requirements-dev.txt | 3 +++ requirements.txt | 6 ++++++ setup.py | 15 ++++++--------- 3 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 requirements-dev.txt create mode 100644 requirements.txt diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..84ae438 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +coverage >= 4.5 +coveralls >= 1.3 +pytest >= 3.4 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7bd6ee5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +choicemodels >= 0.2.dev4 +numpy >= 1.14 +orca >= 1.4 +pandas >= 0.22 +statsmodels >= 0.9 +urbansim >= 3.1 diff --git a/setup.py b/setup.py index 0a3b2a6..fd15568 100644 --- a/setup.py +++ b/setup.py @@ -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.dev16', @@ -13,14 +17,7 @@ '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=[ - 'choicemodels >= 0.2.dev4', - 'numpy >= 1.14', - 'orca >= 1.4', - 'pandas >= 0.22', - 'statsmodels >= 0.9', - 'urbansim >= 3.1' - ] -) + install_requires=requirements From 066ea9fe6b17c68070f25974ba40bb48edabac71 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 14:01:21 -0800 Subject: [PATCH 09/18] Fixing steup typo --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index fd15568..e72dfba 100644 --- a/setup.py +++ b/setup.py @@ -21,3 +21,4 @@ ], packages=find_packages(exclude=['*.tests']), install_requires=requirements +) \ No newline at end of file From 2f72915bbad0b118c6bdbcb40e65cbd80edb93b9 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 14:15:06 -0800 Subject: [PATCH 10/18] Comments for requirements --- .travis.yml | 2 ++ requirements-dev.txt | 2 ++ requirements-full.txt | 1 + 3 files changed, 5 insertions(+) create mode 100644 requirements-full.txt diff --git a/.travis.yml b/.travis.yml index c76872d..884adc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ python: 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 diff --git a/requirements-dev.txt b/requirements-dev.txt index 84ae438..6b6ca4a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,5 @@ +# requirements for development and testing + coverage >= 4.5 coveralls >= 1.3 pytest >= 3.4 diff --git a/requirements-full.txt b/requirements-full.txt new file mode 100644 index 0000000..4b936f0 --- /dev/null +++ b/requirements-full.txt @@ -0,0 +1 @@ +pylogit >= 0.2 \ No newline at end of file From 187952d0a1c4288afc5cc6ff9fbd5aac934a194f Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 14:26:29 -0800 Subject: [PATCH 11/18] Pytest -> coverage --- .travis.yml | 6 +++--- requirements-full.txt | 2 ++ requirements.txt | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 884adc4..a6a5ff3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,8 @@ install: - pip show urbansim_templates script: - - cd urbansim_templates/tests - - pytest *.py + - coverage run --source urbansim_templates -m pytest --verbose after_success: - - coverage report -m \ No newline at end of file + - coverage report -m + - coveralls \ No newline at end of file diff --git a/requirements-full.txt b/requirements-full.txt index 4b936f0..b339d94 100644 --- a/requirements-full.txt +++ b/requirements-full.txt @@ -1 +1,3 @@ +# additional requirements for less-used templates + pylogit >= 0.2 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 7bd6ee5..a9ddfa2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +# minimal requirements for model management and core templates + choicemodels >= 0.2.dev4 numpy >= 1.14 orca >= 1.4 From ff48f7e5c21097283e4d489a6d3234b711ac3b6f Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 14:39:10 -0800 Subject: [PATCH 12/18] Running tests from correct directory --- .travis.yml | 3 ++- urbansim_templates/tests/.gitignore | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a6a5ff3..e5d7aa8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,8 @@ install: - pip show urbansim_templates script: - - coverage run --source urbansim_templates -m pytest --verbose + - cd urbansim_templates/tests + - coverage run -m pytest --verbose after_success: - coverage report -m diff --git a/urbansim_templates/tests/.gitignore b/urbansim_templates/tests/.gitignore index 763624e..068415c 100644 --- a/urbansim_templates/tests/.gitignore +++ b/urbansim_templates/tests/.gitignore @@ -1 +1,2 @@ +.coverage __pycache__/* \ No newline at end of file From 06a52706b408a0abeb72ff8de56b3da89a39043c Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 14:48:06 -0800 Subject: [PATCH 13/18] Fixing source, adding coveralls --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e5d7aa8..9228b92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ install: script: - cd urbansim_templates/tests - - coverage run -m pytest --verbose + - coverage run --source urbansim_templates -m pytest --verbose after_success: - coverage report -m From bfa272b910baef8e275ed4ec6470c94826df3abf Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 14:53:07 -0800 Subject: [PATCH 14/18] Build status badges --- .travis.yml | 4 ++-- README.md | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9228b92..514e876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,8 @@ install: script: - cd urbansim_templates/tests - - coverage run --source urbansim_templates -m pytest --verbose + - coverage run --source urbansim_templates --module pytest --verbose after_success: - - coverage report -m + - coverage report --show-missing - coveralls \ No newline at end of file diff --git a/README.md b/README.md index 3cf1389..fb34192 100644 --- a/README.md +++ b/README.md @@ -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. From 0d2d0ae4c7e74f7062181036994e5f508e030325 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Wed, 7 Nov 2018 15:05:49 -0800 Subject: [PATCH 15/18] Trying python 3.7 --- .travis.yml | 7 +++++++ requirements-dev.txt | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 514e876..a627342 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,13 @@ python: - '3.5' - '3.6' +# Temporary solution for Python 3.7 until it's more cleanly supported +matrix: + include: + - python: '3.7' + dist: xenial + sudo: true + install: - pip install git+git://github.com/udst/choicemodels.git - pip install . diff --git a/requirements-dev.txt b/requirements-dev.txt index 6b6ca4a..cb8cecb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ # requirements for development and testing -coverage >= 4.5 -coveralls >= 1.3 -pytest >= 3.4 +coverage +coveralls +pytest From b54fb9c6a380bad3bc92de6578eb4c3228e74203 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Thu, 8 Nov 2018 10:04:25 -0800 Subject: [PATCH 16/18] Allow python 3.7 failure --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a627342..b10bf4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,14 @@ python: - '3.5' - '3.6' -# Temporary solution for Python 3.7 until it's more cleanly supported matrix: include: - - python: '3.7' + - 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 From 8bed420e7309f0b4324dadca722418afa6e91084 Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Thu, 8 Nov 2018 17:16:25 -0800 Subject: [PATCH 17/18] Adding patsy to requirements --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a9ddfa2..286508c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,6 @@ choicemodels >= 0.2.dev4 numpy >= 1.14 orca >= 1.4 pandas >= 0.22 -statsmodels >= 0.9 +patsy >= 0.4 +statsmodels >= 0.8 urbansim >= 3.1 From d6426a08c05e6f2eadcb04602bbc703c454f6f2b Mon Sep 17 00:00:00 2001 From: Sam Maurer Date: Thu, 8 Nov 2018 17:17:04 -0800 Subject: [PATCH 18/18] Updating version --- setup.py | 2 +- urbansim_templates/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e72dfba..37164f0 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='urbansim_templates', - version='0.1.dev16', + version='0.1.dev17', description='UrbanSim extension for managing model steps', author='UrbanSim Inc.', author_email='info@urbansim.com', diff --git a/urbansim_templates/__init__.py b/urbansim_templates/__init__.py index 94611bd..09d0223 100644 --- a/urbansim_templates/__init__.py +++ b/urbansim_templates/__init__.py @@ -1 +1 @@ -version = __version__ = '0.1.dev16' +version = __version__ = '0.1.dev17'