https://github.com/andreas-bauer/cira
Python package for functions around the causality in requirements artifacts (CiRA) initiative.
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 5 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.2%) to scientific vocabulary
Repository
Python package for functions around the causality in requirements artifacts (CiRA) initiative.
Basic Info
- Host: GitHub
- Owner: andreas-bauer
- License: apache-2.0
- Language: Python
- Default Branch: main
- Homepage: http://www.cira.bth.se
- Size: 320 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
CiRA Pipeline
Summary of Artifact
This repostitory contains a Python implementation of the functions around the causality in requirements artifacts (CiRA) initiative. The initiative is centered around the notion of causal requirements and causality extraction for automatic test case generation.
Features
The main pipeline offers the following functionality:
- Classifying a sentence regarding its causality (binary classification: causal/non-causal)
- Labeling the elements of a causal relationship within a causal sentence.
- Transforming a labeled sentence into a cause-effect graph representing the causal relationship.
- Transforming a cause-effect graph into a minimal set of test cases (test suite) asserting the behavior implied by the sentence.
Example
The features can be visualized considering the following example sentence:
If an error is present and the debugger is active or an exception is triggered then a log entry will be created.
1. Classification
This contrived requirement represents a causal relationship between four events, hence the binary classifier will classify it as causal.
2. Labeling
Labeling the sentence will produce a list of labels that can be visualized as follows (visualization using labviz):
Every label consists of a type (e.g., Cause1, Variable), and a begin and end index, representing the characters it spans across. These labels make explicit, which role each part of the sentence takes in the causal relationship.
3. Graph Construction
Based on these labels, the causal relationship can be reconstructed in the form of a cause-effect graph (visualization using labviz):
The cause-effect graph represents the causal relationship implied by the natural language sentence, but is much easier to process.
4. Test Case Generation
A minimal set of test cases covering the requirement can be derived from this cause-effect graph:
| id | an exception | an error | the debugger | a log entry | |---|---|---|---|---| | 1 | is triggered | not is present | is active | will be created | | 2 | is triggered | is present | not is active | will be created | | 3 | not is triggered | is present | is active | will be created | | 4 | not is triggered | not is present | is active | not will be created | | 5 | not is triggered | is present | not is active | not will be created |
The first three columns after the index represent the input values and the last column represents the expected outcome. These five test cases completely cover the requirement from a combinatorial standpoint.
Development
Setup
Local Development
This package is built and tested using Python 3.10.0. To use the CiRA pipeline locally, perform the following steps:
- Make sure the Rust compiler is installed on your system, as the
tokenizerpackage depends on it. - Install all required dependencies via
pip3 install -e ".[dev]"orpip3 install -e .if you only want production dependencies. - Download and unzip the pre-trained classification and labeling models or use the
download-models.shscript. - Create a
.envfile and specify the variablesMODEL_CLASSIFICATIONandMODEL_LABELINGwith the location of the respective models.
Development inside a Docker Container
You can develop inside a Docker container using a pre-build image that contains all dependencies and the recommended classification and labeling models.
For this setup, you need
Use then the Remote-Containers: Open Workspace in Container... command to open the project inside the container.
You can find detailed information about the development container setup here.
Usage
To use the CiRA pipeline, instantiate a src.cira.CiRAConverter object and specify the location of the pre-trained models. Then, use the high-level functionality as shown in the demonstration.ipynb file.
Dockerization
REST API
The CiRA functionality can also be provided by a single Docker container based on Dockerfile.
Build and run the Docker container via docker compose up.
CiRA's functionality can then be accessed at localhost:8080.
Check localhost:8080\docs while the container is running to access the specification of the API.
Base image cira-dev
The application Docker image and the development container setup are based on the cira-dev image and is present in this repository's packages section.
Tests
Run all tests via pytest.
Owner
- Name: Andreas Bauer
- Login: andreas-bauer
- Kind: user
- Location: Germany | Sweden
- Repositories: 5
- Profile: https://github.com/andreas-bauer
GitHub Events
Total
Last Year
Dependencies
- actions/checkout v3 composite
- docker/build-push-action v3 composite
- docker/login-action v2 composite
- docker/metadata-action v4 composite
- actions/cache v3 composite
- actions/checkout v3 composite
- docker/build-push-action v3 composite
- docker/login-action v2 composite
- docker/metadata-action v4 composite
- actions/checkout v3 composite
- ghcr.io/julianfrattini/cira-dev latest build
- fastapi ==0.85.0
- numpy ==1.23
- pydantic ==1.10.2
- python-dotenv ==0.20
- pytorch_lightning ==1.7
- tabulate ==0.8.10
- torch ==1.12
- transformers ==4.10
- uvicorn ==0.18.3