Skip to main content

Scenario Instance Population Parser

Parses a .sip scenario instance population file into an abstract syntax tree for downstream Blueprint modules

Parses a *.sip file (Scenario Instance Population) to yield an initial instance population.

📖 The sip modeling language is fully documented in the project wiki.

Why you need this

Before executing your system models, you need to define an initial population of instances, attribute values, and initial states. In the modeled elevator management (EVMAN) domain for example, you might specify a single Bank with two Shafts and several Floors. Starting off, one of the Shafts might be in service while the other is out of service.

Having set this stage, you can run any number of scenarios against that initial population.

The population is provided as a sip file to this sip parser which generates an AST (abstract syntax tree) as input to some downstream module. For example, the Blueprint popdata module imports the sip parser and passes in your .sip file.

So you don't typically run the sip parser by itself unless you are performing diagnostics or engineering an updated toolchain that doesn't feed into popdata.

Installation

Create or use a python 3.11+ environment. Then

% pip install sip-parser

At this point you can invoke the parser via the command line or from your python script.

From your python script

You need this import statement at a minimum:

from sip_parser.parser import SIParser

You can then specify a path as shown:

result = SIParser.parse_file(file_input=path_to_file, debug=False)

Here result will be a Scenario named tuple holding the scenario name and a dictionary of classes keyed by class name. Each value is a ClassModelPopulation named tuple holding the column header and the population of instance rows. You may find the header of the visitor.py file helpful in interpreting these results, and the Parser output wiki page breaks the whole structure down with examples.

The parser checks syntax only. It never reads the class or state models, so it cannot tell you that a class, attribute or state you named doesn't exist, or that a row is a value short. Those checks belong to whatever consumes the result.

From the command line

This is not the intended usage scenario, but may be helpful for testing or exploration. Since the parser may generate some diagnostic info you may want to create a fresh working directory and cd into it first. From there...

% sip EVMAN_three_bank1.sip

The .sip extension is not necessary, but the file must contain sip text. A successful parse just reports No problemo; anything else raises a parse error naming the line and column where the grammar gave up.

See this repository's wiki for more about the sip language. The grammar is defined in the sip.peg file. (if the link breaks after I do some update to the code, just browse through the code looking for the sip.peg file, and let me know so I can fix it)

You can also specify a debug option like this:

% sip EVMAN_three_bank1.sip -D

This will create a diagnostics folder in your current working directory and deposit a couple of PDFs defining the parse of both the sip grammar: si_model.pdf and your supplied text: si_parse_tree.pdf. These are rendered with graphviz, so you'll need dot on your path to get them.

You should also see a file named SI_parser.log in your current working directory

Download files

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

Source Distribution

sip_parser-0.2.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sip_parser-0.2.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file sip_parser-0.2.2.tar.gz.

File metadata

  • Download URL: sip_parser-0.2.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for sip_parser-0.2.2.tar.gz
Algorithm Hash digest
SHA256 83dcb0ee0b84a208c9012c065e1ce9adda9f324c849f3d66f2f1b8b92b3d48f1
MD5 94753dd8be6cf969c2722e79b91334d5
BLAKE2b-256 c3cdc22309176d51eca992183cbcf2a181557459cec2438f9c92a63b3c3e7f3f

See more details on using hashes here.

File details

Details for the file sip_parser-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: sip_parser-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for sip_parser-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc85b9eec392383752176238357e5696ea3380db0509f15231c1388fe8e9f364
MD5 7d5d4931c64f48165cb51fef9bf7dfee
BLAKE2b-256 1b95d7669b06644f2b9866483082bb181db1549c1c451e0456961fb9dc777e86

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page