Skip to content

Commit

Permalink
Update development environment to OpenPaths EMME 24
Browse files Browse the repository at this point in the history
  • Loading branch information
samakinen committed Jun 26, 2024
1 parent 6d71dd1 commit 6d25939
Show file tree
Hide file tree
Showing 4 changed files with 452 additions and 343 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.11
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.11
- name: Run tests
run: |
python -m pip install --upgrade pip
pip install pipenv
cd Scripts
cp .env-win .env
pipenv --python 3.7 install --dev
pipenv --python 3.11 install --dev
pipenv run pytest -s tests
63 changes: 31 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ This repository contains python files for Helmet 4.1 Model System. Source codes
## Usage

You can run HELMET 4.1 from the command line or by using [helmet-ui](https://github.com/HSLdevcom/helmet-ui).
In this chapter, we will guide you how to install HELMET 4.1 to work with Inro EMME software from the command line.
The user is not expected to install any new software apart from [helmet-model-system](https://github.com/HSLdevcom/helmet-model-system) and EMME.
In this chapter, we will guide you how to install HELMET 4.1 to work with Bentley OpenPaths EMME software from the command line.
The user is not expected to install any new software apart from [helmet-model-system](https://github.com/HSLdevcom/helmet-model-system) and OpenPaths EMME.

If you do not have an Emme license or you wish to develop HELMET 4.1 further, please scroll down to [Development](#development) chapter.
If you do not have an Bentley OpenPaths license or you wish to develop HELMET 4.1 further, please scroll down to [Development](#development) chapter.

### Setup

From this repository, copy the contents of the [Scripts](Scripts) folder to your computer.

In production, we are using Python 3.7 which is supported by and installed together with INRO Emme software.
We are using those Python dependencies that come with Inro EMME installation.
In production, we are using Python 3.11 which is supported by and installed together with Bentley OpenPaths EMME software.
We are using those Python dependencies that come with Bentley OpenPaths EMME installation.
To get access to these dependencies, you need to add them to your local PATH variable:

1. Open Control Panel.
2. Go to User Accounts, then click again User Accounts, then select from the left hand menu "Change my environment variables".
3. From the top box ("User variables for USERNAME"), find and select "Path" variable, and click "Edit...".
4. Click "New" and write `%EMMEPATH%\Programs`.
5. Click "New" and write `%EMMEPATH%\Python37`.
6. Click "New" and write `%EMMEPATH%\Python37\Scripts`.
5. Click "New" and write `%EMMEPATH%\Python311`.
6. Click "New" and write `%EMMEPATH%\Python311\Scripts`.
7. Click OK in the "Edit environment variable" window, and then click OK again in the "Environment Variables" window.

Emme assignment can be tested without further configuration.
EMME assignment can be tested without further configuration.
Open command line to your local Scripts folder and write:

```
Expand All @@ -37,12 +37,12 @@ python -m tests.emme_only.test_assignment

This will create a small EMME test network and run test assignments on it.

You can also initialize a proper Emme project (if you do not want to use the test network):
You can also initialize a proper EMME project (if you do not want to use the test network):

1. Open Emme desktop application.
1. Open OpenPaths EMME desktop application.
2. Create new project in which the path should match your project name and path.
3. Follow [external instructions](https://hsldevcom.github.io/helmet-ui/sijopankki.html) to configure the details of the Emme project.
Now, your working folder is filled with Emme project specific folders and files.
3. Follow [external instructions](https://hsldevcom.github.io/helmet-ui/sijopankki.html) to configure the details of the EMME project.
Now, your working folder is filled with EMME project specific folders and files.

### Running

Expand All @@ -59,46 +59,46 @@ Run `python helmet.py --help` to see parameter syntax.

## Development

If you do not have INRO Emme license or you wish to develop HELMET 4.1 source code, you need to set up a development environment.
If you do not have Bentley OpenPaths license or you wish to develop HELMET 4.1 source code, you need to set up a development environment.
Although not covered here, installing [Git](https://git-scm.com/downloads) is highly recommended!

### Environment and dependencies

We are using Python 3.7 because it is supported by INRO Emme 4.5 software.
We are using Python 3.11 because it is supported by Bentley OpenPaths EMME 24 software.

1. Install Python 3.7.
2. Add the path were you installed python (e.g., `C:\Python37`) and `C:\Python37\Scripts`
1. Install Python 3.11.
2. Add the path were you installed python (e.g., `C:\Python311`) and `C:\Python311\Scripts`
to your local PATH variable in "Environment Variables".
3. Open a new Command Prompt and type `python --version`.
You should get `Python 3.7.9` or some other Python 3.7 version.
You should get `Python 3.11.9` or some other Python 3.11 version.

`pip` is the recommended package installer for Python.
The normal Python installation routine installs `pip` to `C:\Python37\Scripts`.
The normal Python installation routine installs `pip` to `C:\Python311\Scripts`.
Type `pip --version` to Command Prompt to check if `pip` is installed and in your PATH.
The command should return `pip 20.1.1 from c:\python38\lib\site-packages\pip (python 3.7)` (`pip` version may vary).
The command should return `pip 24.1 from c:\python311\lib\site-packages\pip (python 3.11)` (`pip` version may vary).

We are using `pipenv` to import the same open source libraries which INRO Emme software uses.
We are using `pipenv` to import the same open source libraries which Bentley OpenPaths EMME software uses.
`pipenv` isolates our environment from the other global Python modules and makes sure we don't break anything with our setup.
Optional introduction to `pipenv` can be found from [Python docs](https://docs.python-guide.org/dev/virtualenvs/)
or [Jonathan Cutrer's blog](https://jcutrer.com/python/pipenv-pipfile).

1. Open Command Prompt.
2. Install `pipenv` by running `python -m pip install --user pipenv`.
`pipenv` should now be installed in `%APPDATA%\Python\Python37\Scripts`
(e.g. `C:\Users\USERNAME\AppData\Roaming\Python\Python37\Scripts`).
3. Add `%APPDATA%\Python\Python37\Scripts` to your local PATH variable.
`pipenv` should now be installed in `%APPDATA%\Python\Python311\Scripts`
(e.g. `C:\Users\USERNAME\AppData\Roaming\Python\Python311\Scripts`).
3. Add `%APPDATA%\Python\Python311\Scripts` to your local PATH variable.
1. Open Control Panel.
2. Go to User Accounts, then click again User Accounts, then select from the left hand menu "Change my environment variables".
3. From the top box ("User variables for USERNAME"), find and select "Path" variable, and click "Edit...".
4. Click "New" and write `%APPDATA%\Python\Python37\Scripts`.
4. Click "New" and write `%APPDATA%\Python\Python311\Scripts`.
5. Click OK in the "Edit environment variable" window, and then click OK again in the "Environment Variables" window.
4. Close and reopen Command Prompt and check that `pipenv` is recognised by typing `pipenv --version`.
It should return `pipenv, version 2020.11.15` (`pipenv` version may vary).
It should return `pipenv, version 2024.0.1` (`pipenv` version may vary).
5. Download [helmet-model-system](https://github.com/HSLdevcom/helmet-model-system) repository
and open a Command Prompt to its "Scripts" folder.
6. Install dependencies from `Pipfile`:
- First setup: `pipenv --python 3.7 install --dev`
- Additional syncing if new packages are added: `pipenv --python 3.7 sync --dev`
- First setup: `pipenv --python 3.11 install --dev`
- Additional syncing if new packages are added: `pipenv --python 3.11 sync --dev`
7. Depending on your operating system, rename either `.env-win` (Windows) or `.env-nix` (Linux) to `.env`.
In Windows, you can do this in Command Propmpt by typing `copy .env-win .env`.

Expand Down Expand Up @@ -139,7 +139,7 @@ Refer to this manual: [https://hsldevcom.github.io/helmet-docs/kaytto-ohje.html#

#### Run your first demo model run
1. In case your scenario name is not `test`, copy the `helmet-model-system\tests\test_data\Results\test\Matrices` folder to `[your-result-folder]\[your-scenario-name]\Matrices`.
2. Select scenario with checkbox and click `Käynnistä (1) skenaariota`. When running the first model run again and again, just do #2. When you create more scenarios, always copy matrices (#1) first to a new location. (This is a demo model thing that needs to be done because we are independent of Emme.)
2. Select scenario with checkbox and click `Käynnistä (1) skenaariota`. When running the first model run again and again, just do #2. When you create more scenarios, always copy matrices (#1) first to a new location. (This is a demo model thing that needs to be done because we are independent of EMME.)

#### Running mock assignment in command line
Alternatively, you can run the mock assignment with the help of command line
Expand All @@ -157,9 +157,8 @@ Alternatively, you can run the mock assignment with the help of command line

The following extensions are recommended when developing with Visual Studio Code:

- [Python extension v2023.25.XXX](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
(version >=2024.0.0 comes with pytest 8, which does not support python 3.7)
- [Python Debugger v2024.0.XXX](https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy)
- [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
- [Python Debugger](https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy)

Alternatively, these test views seem to work with any version of the Python and Python Debugger extensions:

Expand All @@ -175,7 +174,7 @@ A couple of tips to get it all working:

### OMX

Emme supports OpenMatrix library for exporting matrices.
OpenPaths EMME supports OpenMatrix library for exporting matrices.

- More info here: https://github.com/osPlanning/omx/wiki/EMME
- Python source codes: https://github.com/osPlanning/omx-python
Expand Down
14 changes: 7 additions & 7 deletions Scripts/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ pylint = "*"
rope = "*"

[packages]
pandas = "==0.24.2"
pandas = "==2.0.2"
openpyxl = "*"
openmatrix = "==0.3.3"
numpy = "==1.16.2"
numexpr = "==2.7.1"
tables = "==3.5.1"
shapely = "*"
openmatrix = "==0.3.5"
numpy = "==1.26.2"
numexpr = "==2.8.4"
tables = "==3.8.0"
shapely = "==2.0.1"

[requires]
python_version = "3.7"
python_version = "3.11"
Loading

0 comments on commit 6d25939

Please sign in to comment.