{"id":27062882,"url":"https://github.com/doganulus/python-monitors","last_synced_at":"2025-04-05T15:27:20.424Z","repository":{"id":57457269,"uuid":"156097663","full_name":"doganulus/python-monitors","owner":"doganulus","description":"A pure Python package to monitor formal specifications over temporal sequences","archived":false,"fork":false,"pushed_at":"2019-12-10T22:23:41.000Z","size":46052,"stargazers_count":17,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T14:46:41.011Z","etag":null,"topics":["monitoring","regular-expressions","runtime-verification","temporal-logic"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doganulus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-04T15:44:05.000Z","updated_at":"2025-01-16T21:49:17.000Z","dependencies_parsed_at":"2022-09-19T09:01:07.079Z","dependency_job_id":null,"html_url":"https://github.com/doganulus/python-monitors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doganulus%2Fpython-monitors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doganulus%2Fpython-monitors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doganulus%2Fpython-monitors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doganulus%2Fpython-monitors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doganulus","download_url":"https://codeload.github.com/doganulus/python-monitors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247356705,"owners_count":20925883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["monitoring","regular-expressions","runtime-verification","temporal-logic"],"created_at":"2025-04-05T15:27:19.907Z","updated_at":"2025-04-05T15:27:20.417Z","avatar_url":"https://github.com/doganulus.png","language":"Python","readme":"# About python-monitors\n `python-monitors` is a pure Python package to monitor formal specifications over temporal sequences. It supports several specification languages such as regular expressions and variants of temporal logic. The usage is fairly easy thanks to Python and allows fast prototyping of applications that monitor temporal sequences using these specifications. \n \n\u003e **WARNING**: This repository is depreciated in favor of the project [Reelay](https://github.com/doganulus/reelay) but will remain as a pure Python solution albeit limited in functionatity and speed. Reelay implements the same runtime monitors and more in C++, which are accessible from Python via bindings.\n     \n\n# Install\nThe latest release of the package can be installed via `pip` such that\n\n    pip install python-monitors\n\nThis command will also install dependencies `python-intervals` and `antlr4-python3-runtime`. Alternatively, you can install directly from this repository by running the command \n\n    pip install git+https://github.com/doganulus/python-monitors.git \n\n# Use\n\n## MTL over propositions\n\nFirst generate a monitor from past Metric Temporal Logic (MTL) formula:\n\n    from monitors import mtl\n     \n\tmy_mtl_monitor = mtl.monitor(\"always(q -\u003e once[2,4](p))\")\n\nThen process a data sequence (over propositions) by updating the monitor and collecting the output at each step:\n\n\tdata = dict(\n\t\tp = [False, True,  False, False, False, False, False, True,  False, False, False, False, False, False, False], \n\t\tq = [False, False, False, False, False, True,  False, False, False, False, False, False, False, False, True ]\n\t)\n     \n\tfor p, q in zip(data['p'], data['q']):\n     \n\t\toutput = my_mtl_monitor.update(p = p, q = q)\n     \n\t\tprint(my_mtl_monitor.time, output, my_mtl_monitor.states)\n\n\n## MTL over predicates (also known as STL)\n\nAny Boolean-valued Python function can be used as a predicate in MTL formulas. They are passed to monitor construction via a dictionary as follows:\n\n\tdef my_predicate(x):\n\t    return x \u003c 5\n    \n    # Named parameters should share the same strings in the expression \n    my_mtl_monitor = mtl.monitor(\"always[0,5](p(x))\", p=my_predicate)\n     \n    for n in [9, 13, 4, 1, 2, 3,1,1,1,2]:\n\t    output = my_mtl_monitor.update(x = n)\n\t    print(my_mtl_monitor.time, my_predicate(n), output, my_mtl_monitor.states)\n\t\n\n## Regular expressions over propositions and predicates\n\nRegular expressions over propositions and predicates are available in a similar fashion:\n\n    from monitors import regexp\n     \n    def pred1(x):\n        return x \u003c 5\n     \n    def pred2(x):\n\t    return x \u003e 12\n     \n\t# Named parameters should share the same strings in the expression \n    my_reg_monitor = regexp.monitor(\"True*; p1(x); p2(x)+; p1(x)+\", p1=pred1, p2=pred2)\n     \n    for n in [1, 1, 1, 1, 13, 13, 14, 1, 1, 2]:\n\t    output = my_reg_monitor.update(x = n)\n\t    print(output, my_reg_monitor.states)\n\n# Cite\nFor MTL monitoring algorithm, please cite [Online Monitoring of Metric Temporal Logic using Sequential Networks](https://arxiv.org/abs/1901.00175). For RE monitoring algorithm, please cite [Sequential Circuits from Regular Expressions Revisited](https://arxiv.org/abs/1801.08979).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoganulus%2Fpython-monitors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoganulus%2Fpython-monitors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoganulus%2Fpython-monitors/lists"}