Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
caisar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
caisar
Commits
99e351a6
Commit
99e351a6
authored
9 months ago
by
Aymeric Varasse
Browse files
Options
Downloads
Patches
Plain Diff
[prover] Minor fixes and formatting for runMarabou
parent
7dc9e16b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/runMarabou.py
+21
-42
21 additions, 42 deletions
bin/runMarabou.py
with
21 additions
and
42 deletions
bin/runMarabou.py
+
21
−
42
View file @
99e351a6
...
...
@@ -4,9 +4,7 @@ Modified by the AISER team, Software Safety and Security Laboratory, CEA-List.
This file is part of CAISAR.
This file is used for integrating Marabou, via its Python interface, in CAISAR.
"""
"""
Top contributors (to current version):
- Andrew Wu
...
...
@@ -17,38 +15,32 @@ All rights reserved. See the file COPYING in the top-level source
directory for licensing information.
"""
class
WrongNetFormat
(
Exception
):
def
__init__
(
self
,
networkPath
):
self
.
message
=
(
f
"
Network
{
networkPath
}
has an unrecognized extension.
"
f
"
The network must be in .pb, .nnet or .onnx format.
"
)
super
().
__init__
(
self
.
message
)
import
argparse
from
importlib.metadata
import
version
import
os
import
pathlib
import
shutil
import
subprocess
import
sys
import
tempfile
from
importlib.metadata
import
version
from
maraboupy
import
Marabou
,
MarabouCore
# type: ignore
from
maraboupy
import
Marabou
from
maraboupy
import
MarabouCore
class
WrongNetFormat
(
Exception
):
def
__init__
(
self
,
networkPath
):
self
.
message
=
(
f
"
Network
{
networkPath
}
has an unrecognized extension.
"
f
"
The network must be in .pb, .nnet or .onnx format.
"
)
super
().
__init__
(
self
.
message
)
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
str
(
pathlib
.
Path
(
__file__
).
parent
.
absolute
()),
"
../
"
)
)
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
str
(
pathlib
.
Path
(
__file__
).
parent
.
absolute
()),
"
../
"
))
def
maraboupy_version
(
marabou_binary
:
str
):
result
=
subprocess
.
run
(
[
marabou_binary
,
"
--version
"
],
capture_output
=
True
,
text
=
True
)
result
=
subprocess
.
run
([
marabou_binary
,
"
--version
"
],
capture_output
=
True
,
text
=
True
)
if
result
.
returncode
!=
0
:
print
(
f
"
Error running
{
marabou_binary
}
--version
"
)
sys
.
exit
(
1
)
...
...
@@ -62,9 +54,7 @@ def maraboupy_version(marabou_binary: str):
def
arguments
():
parser
=
argparse
.
ArgumentParser
(
description
=
"
Thin wrapper around Maraboupy executable
"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
Thin wrapper around Maraboupy executable
"
)
parser
.
add_argument
(
"
network
"
,
type
=
str
,
...
...
@@ -72,15 +62,9 @@ def arguments():
default
=
None
,
help
=
"
The network file name, the extension can be only .pb, .nnet, and .onnx
"
,
)
parser
.
add_argument
(
"
prop
"
,
type
=
str
,
nargs
=
"
?
"
,
default
=
None
,
help
=
"
The property file name
"
)
parser
.
add_argument
(
"
-t
"
,
"
--timeout
"
,
type
=
int
,
default
=
10
,
help
=
"
Timeout in seconds
"
)
parser
.
add_argument
(
"
--temp-dir
"
,
type
=
str
,
default
=
"
/tmp/
"
,
help
=
"
Temporary directory
"
)
parser
.
add_argument
(
"
prop
"
,
type
=
str
,
nargs
=
"
?
"
,
default
=
None
,
help
=
"
The property file name
"
)
parser
.
add_argument
(
"
-t
"
,
"
--timeout
"
,
type
=
int
,
default
=
10
,
help
=
"
Timeout in seconds
"
)
parser
.
add_argument
(
"
--temp-dir
"
,
type
=
str
,
default
=
"
/tmp/
"
,
help
=
"
Temporary directory
"
)
marabou_path
=
shutil
.
which
(
"
Marabou
"
)
parser
.
add_argument
(
"
--marabou-binary
"
,
...
...
@@ -103,15 +87,13 @@ def main():
marabou_binary
=
args
.
marabou_binary
if
not
os
.
access
(
marabou_binary
,
os
.
X_OK
):
sys
.
exit
(
'"
{}
"
does not exist or is not executable
'
.
format
(
marabou_binary
)
)
sys
.
exit
(
'"
{}
"
does not exist or is not executable
'
.
format
(
marabou_binary
))
else
:
if
args
.
version
:
print
(
f
"
{
maraboupy_version
(
marabou_binary
)
}
"
)
else
:
assert
args
.
network
!=
None
assert
args
.
prop
!=
None
assert
args
.
network
is
not
None
assert
args
.
prop
is
not
None
networkPath
=
args
.
network
suffix
=
networkPath
.
split
(
"
.
"
)[
-
1
]
...
...
@@ -133,10 +115,7 @@ def main():
print
(
"
Running Marabou with the following arguments:
"
,
unknown
)
subprocess
.
run
(
[
marabou_binary
]
+
[
"
--input-query={}
"
.
format
(
name
)]
+
[
"
--timeout={}
"
.
format
(
timeout
)]
+
unknown
[
marabou_binary
]
+
[
"
--input-query={}
"
.
format
(
name
)]
+
[
"
--timeout={}
"
.
format
(
timeout
)]
+
unknown
)
os
.
remove
(
name
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment