• Stars
    star
    265
  • Rank 153,713 (Top 4 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

systems is a set of tools for describing, running and visualizing systems diagrams.

Systems

systems is a set of tools for describing, running and visualizing systems diagrams.

Installation directions are below, and then get started by working through the tutorial or reading through the Jupyter notebook example example.

For a more in-depth look at the system syntax, please read the syntax specification.

Quickest start

Follow the installation instructions below, then write a system definition such as:

Start(10)
Start  > Middle @ 2
Middle > End

You can then evaluate your system (use --csv for an importable format):

cat tmp.txt | systems-run -r 3

        Start   Middle  End
0       10      0       0
1       8       2       0
2       6       3       1
3       4       4       2

See the tutorial for more detailed starting information.

Installation

To install via PyPi:

pip install systems

To install for local development:

git clone https://github.com/lethain/systems.git
cd systems
python3 -m venv ./env
source ./env/bin/activate
python setup.py develop

Run tests via:

python3 -m unittest tests/test_*.py

Or run a single test via:

python3 tests/test_parse.py TestParse.test_parse_complex_formula

Please open an Github issue if you run into any problems!

Jupyter notebooks

Likely the easiest way to iterate on a model is within a Jupyter notebook. See an example notebook here. To install, follow the installation steps above, and followed by:

# install graphviz
brew install graphviz

# install these additional python packages
pip install jupyter pandas matplotlib

Using the command line tools

There are four command line tools that you'll use when creating and debugging systems/

systems-run is used to run models:

$ cat examples/hiring.txt | systems-run -r 3
PhoneScreens    Onsites Offers  Hires   Employees       Departures
0       0               0       0       0       5               0
1       25              0       0       0       5               0
2       25              12      0       0       5               0
3       25              12      6       0       5               0

systems-viz is used to visualize models into Graphviz:

$ cat examples/hiring.txt | systems-viz
// Parsed
digraph {
  rankdir=LR
  0 [label=Candidates]
  1 [label=PhoneScreens]
  // etc, etc, some other stuff
}

Typically you'll pipe the output of systems-viz into dot, for example

$ cat examples/hiring.txt | systems-viz | dot -Tpng -o tmp.png

systems-format reads in a model, tokenizes it and formats the tokens into properly formatted results. This is similar to gofmt, and could be used for ensuring a consistent house formatting style for your diagrams. (It was primarily implemented to support generating human readable error messages instead of surfacing the tokens to humans when errors arise.)

$ cat examples/hiring.txt | systems-fmt
[Candidates] > PhoneScreens @ 25
PhoneScreens > Onsites @ 0.5
# etc etc

systems-lex generates the tokens for a given system file. This is typically most useful when you're extending the lexer to support new types of functionality, but can also be useful for other kinds of debugging:

$ cat examples/hiring.txt | systems-lex
('lines',
   [('line',
     1,
     [('comment', '# wrap with [] to indicate an infinite stock that')]),
    ('line', 2, [('comment', "# isn't included in each table")]),
('line', 3, [('comment', '# integers are implicitly steady rates')]),
('line',
 4,
     [('infinite_stock', 'Candidates', ('params', [])),
  ('flow_direction', '>'),
      ('stock', 'PhoneScreens', ('params', ())),
      ('flow_delimiter', '@'),
      ('flow', '', ('params', (('formula', [('whole', '25')]),)))]),
...
  ]
)

Error messages

The parser will do its best to give you a useful error message. For example, if you're missing delimiters:

cat examples/no_delim.txt | systems-run
line 1 is missing delimiter '>': "[a] < b @ 25"

At worst, it will give you the line number and line that is creating an issue:

cat examples/invalid_flow.txt | systems-run
line 1 could not be parsed: "a > b @ 0..2"

Uploading distribution

If you are trying to install this on PyPi, the steps are roughly:

python3 -m pip install --user --upgrade pip
python3 -m pip install --user --upgrade wheel
python3 -m pip install --user --upgrade twine
python3 setup.py sdist bdist_wheel
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

That should more or less work. :)

More Repositories

1

staff-eng

Collection of stories of how folks have reached Staff-plus roles in technology.
CSS
207
star
2

extraction

A Python library for extracting titles, images, descriptions and canonical urls from HTML.
Python
146
star
3

Redis-Python-Datastructures

simple python datastructure wrappings for redis
Python
105
star
4

django-monetize

A pluggable Django application for delivering highly targeted advertisement.
Python
86
star
5

apache-log-parser

A Python command-line tool for parsing information from Apache log files.
Python
66
star
6

aym-cms

A Django templating based static CMS.
Python
59
star
7

django-userskins

A pluggable Django app for allowing users to pick among a variety of skins for webapps.
Python
43
star
8

lifeflow

A full featured and opinionated blogging solution using Django
Python
43
star
9

django-springsteen

A Django app for querying Yahoo! BOSS and aggregating service results.
Python
41
star
10

nagios_erlang

Nagios plugins for monitoring Erlang process groups/applications/nodes/etc
Shell
40
star
11

sparklines.js

A javascript library for creating bar and line Sparklines.
JavaScript
40
star
12

log-collector

node.js server for collecting logs and client for monitoring files and sending them to remote collection server
JavaScript
31
star
13

python-markdown-graphviz

support for embedding graphviz graphs inside markdown documents
Python
27
star
14

codernote

a django project for organizing, sharing and rendering code snippets and notes
JavaScript
17
star
15

metawindow

Repository for a PyObjC project built in one of my tutorial series.
Python
14
star
16

BeepBeep-Examples

A collection of BeepBeep examples
Erlang
13
star
17

go-learning-projects

A collection of projects for learning the Go programming language while also learning about the implementation details of open-source technologies you likely already use.
Go
13
star
18

llm-explorer

Experimentation with Streamlit for personal LLM tool
Python
12
star
19

dfsmr

Distributed runner for finite state machines.
Go
11
star
20

rethinkdb-extraction

A very simple example of using RethinkDB along with the Extraction library for a simpler crawler.
Python
11
star
21

distributed-key-value-store-example

an example of a distributed key-value store...
Erlang
11
star
22

django-syntax-colorize

A template filter for Django to apply Pygments syntax coloring to strings.
Python
11
star
23

couchdb_analytics

Erlang application using CouchDB to store visitor analytics for web applications.
Erlang
10
star
24

comfy-django-example

A tutorial that shows how to use CouchDB with Django.
Python
10
star
25

erlang_markdown

Markdown parser written in Erlang.
Erlang
9
star
26

systems-explorations

Examples of using systems library to model dynamic systems.
Jupyter Notebook
9
star
27

notes-djapp-tutorial

The Git repository for the Django, jQuery & Ajax tutorial series.
8
star
28

openai-experiments

Just me playing around with OpenAI
Python
8
star
29

sisyphus

A Redis-backed blog written in Django
Python
8
star
30

techwriters-dev

https://techwriters.dev - a community for authors writing technical content
8
star
31

digg-streaming

Examples for using the Digg Streaming API
Python
8
star
32

Redis-Memory-Usage-Tests

Collection of tests to measure redis memory usage.
Python
8
star
33

misc-clojure-snippets

collection of unorganized clojure snippets of questionable quality
Clojure
8
star
34

papersandsystems

Hold the source code for Papers and Systems!
HTML
7
star
35

resume-interactivity-provider

App for creating static resume-like pages with dynamic interactivity.
JavaScript
7
star
36

reflect-slack-app

A simple example of a Slack application
Python
7
star
37

pandoc-book-example

Python
6
star
38

extraction_tutorial

Working example of GraphQL, Flask and Python3.
Python
6
star
39

vtt_compactor

Compact VTT transcripts into a denser format
Python
6
star
40

mahou

A Cappuccino, Yahoo! BOSS, and Google App Engine based web search
6
star
41

infraeng-changes

git-scraping example monitoring changes to infraeng.dev
Python
5
star
42

python-twitter-remote

Barebones library for using twitter to run remote commands.
Python
5
star
43

python-utilities-misc

Collection of miscellaneous Python utilities.
Python
4
star
44

kappa

A PyObjC based Twitter client
4
star
45

haproxy-parser

Simple parser for HAProxy in Go, plus transforming to JSON.
Go
3
star
46

organize

Python library for parsing in messy real-world data files (CSV, TSV, Excel).
Python
3
star
47

workframe.js

A micro-web-framework for Node.js centered on imperative workflows
JavaScript
3
star
48

bossarray

A Python list like wrapper around the Yahoo BOSS search results.
Python
3
star
49

icarus

Icarus is a minimalistic blog platform for people who want to write Markdown or HTML documents in Git
Go
3
star
50

k8s-fault-injection

Quick proof of concept for running fault injection against Kubernetes deployments.
Python
2
star
51

gareports_reader

Python library for parsing Google Analytics reports.
2
star
52

xlwt-examples-aws-pricing

An example of using the xlwt library to generate an AWS pricing calculator
Python
2
star
53

python_brightkite

A Python wrapper for the Brightkite API
Python
2
star
54

social-context

Python
2
star
55

literal

Utility for maintaining state and rendering templates in text formats.
Rust
2
star
56

gke_ci

A very basic approach for last mile of continuous deployment on Google Container Engine, which updates deployment after successful Container Builds for associated deployments.
Python
2
star
57

lethain

1
star
58

ruby-learning-projects

Learning projects for Ruby.
Ruby
1
star
59

phabulous

A hopefully simpler wrapper around python-phabricator for playing with Phabricator data.
Python
1
star
60

Pitance

A command-line interface for the Pitance project.
1
star
61

comment-rater

Example of a 2-player Game With A Purpose implemented in Node.js
JavaScript
1
star
62

exuberant-sketches

sketches.lethain.com
HTML
1
star