FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Examples/.github/scripts/tla_utils.py at fix-timeout · tlaplus/Examples · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
tlaplus
/
Examples
Public
Notifications
You must be signed in to change notification settings
Fork
224
Star
1.6k
Code
Issues
5
Pull requests
4
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
Examples
/
.github
/
scripts
/
tla_utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
109 lines (98 loc) · 3.16 KB
Breadcrumbs
Examples
/
.github
/
scripts
/
tla_utils.py
Copy path
File metadata and controls
109 lines (98 loc) · 3.16 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from
datetime
import
datetime
import
json
from
os
.
path
import
normpath
,
pathsep
import
subprocess
def
ignore
(
ignored_dirs
,
path
):
"""
Determines whether the given path is covered by paths in the .ciignore
file and thus should be ignored.
"""
return
any
([
normpath
(
path
).
startswith
(
ignore_dir
)
for
ignore_dir
in
ignored_dirs
])
def
is_blank
(
text
):
"""
Whether the given string is composed entirely of space character.
"""
all
([
c
.
isspace
()
for
c
in
text
])
def
get_ignored_dirs
():
"""
Parses the .ciignore file to get the set of ignored directories.
"""
with
open
(
'.ciignore'
,
'r'
)
as
ignore_file
:
return
set
([
normpath
(
line
.
strip
())
for
line
in
ignore_file
.
readlines
()
if
not
line
.
startswith
(
'#'
)
and
not
is_blank
(
line
)
])
def
load_json
(
path
):
"""
Loads the json file at the given path.
"""
with
open
(
normpath
(
path
),
'r'
,
encoding
=
'utf-8'
)
as
file
:
return
json
.
load
(
file
)
def
load_manifest
():
"""
Loads the manifest.json file.
"""
return
load_json
(
'manifest.json'
)
def
load_schema
():
"""
Loads the schema for the manifest.json file.
"""
return
load_json
(
'manifest-schema.json'
)
def
parse_timespan
(
unparsed
):
"""
Parses the timespan format used in the manifest.json format.
"""
pattern
=
'%H:%M:%S'
return
datetime
.
strptime
(
unparsed
,
pattern
)
-
datetime
.
strptime
(
'00:00:00'
,
pattern
)
def
get_run_mode
(
mode
):
"""
Converts the model run mode found in manifest.json into TLC CLI
parameters.
"""
if
type
(
mode
)
is
dict
:
if
'simulate'
in
mode
:
trace_count
=
mode
[
'simulate'
][
'traceCount'
]
return
[
'-simulate'
,
f'num=
{
trace_count
}
'
]
else
:
raise
NotImplementedError
(
f'Undefined model-check mode
{
mode
}
'
)
elif
'generate'
==
mode
:
return
[
'-generate'
]
elif
'exhaustive search'
==
mode
:
return
[]
else
:
raise
NotImplementedError
(
f'Undefined model-check mode
{
mode
}
'
)
def
get_config
(
config
):
"""
Converts the model config found in manifest.json into TLC CLI
parameters.
"""
return
[
'-deadlock'
]
if
'ignore deadlock'
in
config
else
[]
def
check_model
(
module_path
,
model_path
,
mode
,
config
,
timeout
):
"""
Model-checks the given model against the given module.
"""
module_path
=
normpath
(
module_path
)
model_path
=
normpath
(
model_path
)
tlaps_modules
=
normpath
(
'tlapm/library'
)
try
:
tlc
=
subprocess
.
run
(
[
'java'
,
'-Dtlc2.TLC.ide=Github'
,
'-Dutil.ExecutionStatisticsCollector.id=abcdef60f238424fa70d124d0c77ffff'
,
'-XX:+UseParallelGC'
,
'-cp'
,
pathsep
.
join
([
'tla2tools.jar'
,
tlaps_modules
]),
'tlc2.TLC'
,
module_path
,
'-config'
,
model_path
,
'-workers'
,
'auto'
,
'-lncheck'
,
'final'
,
'-cleanup'
]
+
get_config
(
config
)
+
get_run_mode
(
mode
),
capture_output
=
True
,
timeout
=
timeout
)
return
(
tlc
,
False
)
except
subprocess
.
TimeoutExpired
:
return
(
None
,
True
)
Back
|
FazBrowse Home
|
New Git URL