-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d516c29
commit a46c9ef
Showing
17 changed files
with
192 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
ARG PYTHON_VERSION=3.11 | ||
ARG PYTHON_VERSION=3.8 | ||
FROM python:${PYTHON_VERSION} | ||
|
||
|
||
RUN apt-get update && \ | ||
apt-get install -y software-properties-common &&\ | ||
apt update && \ | ||
apt install -y graphviz | ||
# add-apt-repository universe && \ | ||
|
||
# https://python-poetry.org/docs#ci-recommendations | ||
ENV POETRY_VERSION=1.7.0 | ||
# ENV POETRY_HOME=/opt/poetry | ||
ENV POETRY_VENV=/opt/poetry-venv | ||
|
||
# Tell Poetry where to place its cache and virtual environment | ||
ENV POETRY_CACHE_DIR=/opt/.cache | ||
|
||
# Creating a virtual environment just for poetry and install it with pip | ||
RUN python3 -m venv $POETRY_VENV \ | ||
&& $POETRY_VENV/bin/pip install -U pip setuptools \ | ||
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION} | ||
|
||
# Add Poetry to PATH | ||
ENV PATH="${PATH}:${POETRY_VENV}/bin" | ||
|
||
ENV POETRY_VIRTUALENVS_IN_PROJECT=true | ||
ENV POETRY_VERSION=1.7.0 \ | ||
# Poetry home directory | ||
POETRY_HOME='/usr/local' \ | ||
# Add Poetry's bin folder to the PATH | ||
PATH="/usr/local/bin:$PATH" \ | ||
# Avoids any interactions with the terminal | ||
POETRY_NO_INTERACTION=1 \ | ||
# This avoids poetry from creating a virtualenv | ||
# Instead, it directly installs the dependencies in the system's python environment | ||
POETRY_VIRTUALENVS_CREATE=false | ||
|
||
# System deps: | ||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
# Copy the project files | ||
WORKDIR /home/specless | ||
COPY pyproject.toml poetry.lock /home/specless/ | ||
|
||
# Project initialization and conditionally install cvxopt if on x86 architecture | ||
RUN poetry install --no-interaction | ||
# RUN poetry install --no-interaction && \ | ||
# if [ "$(uname -m)" = "x86_64" ]; then poetry add cvxopt; fi | ||
|
||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import specless as sl # or load from specless.inference import TPOInference | ||
|
||
|
||
def main(): | ||
|
||
### Partial Order Inference | ||
|
||
# Manually prepare a list of demonstrations | ||
demonstrations = [ | ||
["e1", "e2", "e3", "e4", "e5"], # trace 1 | ||
["e1", "e4", "e2", "e3", "e5"], # trace 2 | ||
["e1", "e2", "e4", "e3", "e5"], # trace 3 | ||
] | ||
|
||
# Run the inference | ||
inference = sl.POInferenceAlgorithm() | ||
specification = inference.infer(demonstrations) # returns a Specification | ||
|
||
# prints the specification | ||
print(specification) # doctest: +ELLIPSIS | ||
|
||
# exports the specification to a file | ||
|
||
# drawws the specification to a file | ||
sl.draw_graph(specification, filepath='spec') | ||
|
||
### Timed Partial Order Inference | ||
|
||
# Manually prepare a list of demonstrations | ||
demonstrations: list = [ | ||
[[1, "a"], [2, "b"], [3, "c"]], | ||
[[4, "d"], [5, "e"], [6, "f"]], | ||
] | ||
columns: list = ["timestamp", "symbol"] | ||
|
||
timedtrace_dataset = sl.ArrayDataset(demonstrations, columns) | ||
|
||
# Timed Partial Order Inference | ||
inference = sl.TPOInferenceAlgorithm() | ||
specification: sl.Specification = inference.infer(timedtrace_dataset) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
|
Oops, something went wrong.