Skip to main content

Python support library for SimWrapper BEAM data visualization tool

Project description

SimWrapper Python Tools

Official python library for working with SimWrapper BEAM.

SimWrapper is a data visualization tool for exploring large transport simulation results.

Web browsers all block access to your local filesystem from external websites, for obvious security reasons. The SimWrapper website needs access to model run outputs on your filesystem. This program bridges that gap: it is a command-line tool that starts a local file server in a specific folder, so that you can access the files in that folder using SimWrapper.

About this library

This library contains the "simwrapper" command-line tool, which allows browsing of local files on your PC/laptop using the SimWrapper website.

We are at the very early stages of building this tool. The API will change, things will break, and there are certainly bugs.

  • Our primary goal is to make it easy to get local simulation results viewable using the SimWrapper website.
  • We have only tested this using Anaconda Python. Only Python 3.x is supported.

Installation

Installation requires the pip package manager.

  • Install using pip install beam-viewer
  • To upgrade to the latest version, pip install --upgrade beam-viewer

This package includes an embedded copy of the Javascript code from the SimWrapper project, available separately at https://github.com/simwrapper/simwrapper. That code is under the identical GNU GPL V3 and is embedded here with explicit permission of the author.

Usage

beam-viewer knows three commands.

beam-viewer serve

starts a local file server in the current directory. Run this command, then browse to either https://vsp.berlin/simwrapper or https://activitysim.github.io/dashboard to view your local folder outputs.

beam-viewer here

starts a local copy of the SimWrapper website usually listening on port 8050. Run this command instead of simwrapper serve if you have a machine on your local network which contains outputs you'd like to view (such as a modeling server), and that machine has not been set up with any other file sharing software such as NGINX or Apache.

  • This command is designed to support the use case where an agency has (1) a local network with files stored on a central "modeling server" or file server, and also (2) desktop machines or laptops on the local network that wish to access those files using SimWrapper.
  • Note, it's not a battle-tested multi-threaded web proxy server such as Apache, NGINX, or Gunicorn. Ultimately you may decide that you want to put simwrapper behind a proxy server such as those listed, for improved performance, features, and security.

beam-viewer open [beam|vsp|asim]

opens a new web browser tab AND a local file server in the current directory. The site will only operate as long as you keep that local server running, so don't close the command window.

  • To open on the BEAM site on the web, use beam-viewer open beam
  • You can also run beam-viewer open without specifying an external site. In this case, it will will serve everything from the localhost, including file contents and SimWrapper code itself. This is the same as beam-viewer here except it also opens a browser tab.

All of these commands start a small local file server, listening on a local port number. The site will only operate as long as you keep that local server running: quitting the command with CTRL-C or closing the command window will shut down the server.

Security

When beam-viewer is running, it listens for connections on your network interface. Your computer's firewall rules and router settings determine whether other machines on the network can access the folder, or not.

By default, almost all computers now run firewalls which block external access. If you want the files in your simwrapper folder to be available on your network, you will need to grant firewall permissions, generally meaning you need to authorize incoming network connections for the Python executable, and on the specific port used by SimWrapper.

  • SimWrapper usually runs on ports 8000 and 8050. Starting multiple copies will increment the port numbers by one each time.

Running as HTTPS - required for Safari

Safari blocks HTTPS websites (such as SimWrapper VSP and ASIM) which access localhost resources such as this local simwrapper file server.

We recommend using Google Chrome, Brave, and Microsoft Edge, because they are much faster than Safari or Firefox. But you can run beam-viewer in HTTPS mode by following these extra instructions.

Simwrapper commands accept --key and --cert options to specify the two pieces of a PEM certicate. You can create a PEM certificate for "localhost" and install it in your browser's certificate database with the following commands.

This requires Homebrew, which supplies the brew command.

brew install mkcert nss   # installs mkcert command
mkcert localhost          # Create PEM key/cert files for "localhost"
mkcert -install           # Installs certificates in browser

This creates two files: localhost.pem and localhost-key.pem. Move them somewhere where you cn find them.

Now you can run simwrapper as follows:

  • beam-viewer serve --cert localhost.pem --key localhost-key.pem
  • beam-viewer open beam --cert localhost.pem --key localhost-key.pem
  • The beam-viewer here command does not use or support certificates.

For help or support

SimWrapper is open source software with no guarantees, and is provided under the GNU GPL v3 license. You can post questions, bugs, or updates on the SimWrapper Github issue list, here: http://github.com/simwrapper/simwrapper/issues.

Have fun!

Developing the SimWrapper Python tool

The python beam-viewer tool contains a fully-built static copy of the SimWrapper website in the simwrapper/static folder. Whenever you make changes to the SimWrapper website, you'll need to package up the changes, copy them into this Python project, and build the Python package.

Here are the basic steps to do that:

  • In the SimWrapper javascript project repo:

    • Make any changes to the SimWrapper javascript code as needed, and test vigorously
    • Ensure that both vite.config.js and public/404.html are both set to have prefix "/" instead of "/simwrapper/" or "/dashboard/". The Python tool will not work if there is a URL prefix in the path.
    • Run npm run build to compile everything into the dist folder.
  • Then in this Python repository:

    • Delete all files in the simwrapper/static folder
    • Delete all files in the build folder
    • Copy entire contents from the SimWrapper dist folder (above) to the simwrapper/static folder here
    • Make any needed changes to the Python code in the simwrapper folder here
    • Run make build to generate the Python code

Now you can test your changes locally by running pip install . from the root folder of this project. You probably want to be inside a python environment if you want to isolate your changes during testing.

If everything is running smoothly, then push the project to pip and conda:

Updating pip

  • Commit all your changes: use semantic versioning commit messages ("fix: blah" and "feat: blah")
  • Bump the version number with make version
  • Commit the version bump, and push changes to Github
  • Push to PyPi (pip) with make push
  • Take note of the SHA256 string for the new version.tar.gz at https://pypi.org/project/simwrapper which can be found on the "Download Files" page

Updating conda

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beam-viewer-1.10.0.tar.gz (20.4 MB view details)

Uploaded Source

Built Distribution

beam_viewer-1.10.0-py3-none-any.whl (20.8 MB view details)

Uploaded Python 3

File details

Details for the file beam-viewer-1.10.0.tar.gz.

File metadata

  • Download URL: beam-viewer-1.10.0.tar.gz
  • Upload date:
  • Size: 20.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.11.4 pkginfo/1.7.0 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for beam-viewer-1.10.0.tar.gz
Algorithm Hash digest
SHA256 a266e25bd0d6e6b85e8719969ac741d0488b6850b7b83647919ffb9da971b3d2
MD5 985c46629449078fac3f70d3e0e5bc88
BLAKE2b-256 61026a10163baf450d2d3d98723124f5456023b2276758903314cecdb44bda15

See more details on using hashes here.

File details

Details for the file beam_viewer-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: beam_viewer-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.11.4 pkginfo/1.7.0 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for beam_viewer-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 183dafaa19fb63791b61bf28738a48abe6f6565e0530df2a366fc80e22f1dd68
MD5 323f480965e09349631c2d4d35cafb5d
BLAKE2b-256 851d07281eb7bfb3671f3af1f7dc7616143dd0531f8cd6aa8303ce21ffd61022

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page