Skip to content

Commit 4021e86

Browse files
committed
Manifest generation and state space recording scripts now use split manifests
Signed-off-by: Andrew Helwer <ahelwer@pm.me>
1 parent d5af150 commit 4021e86

3 files changed

Lines changed: 20 additions & 25 deletions

File tree

.github/scripts/generate_manifest.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from check_manifest_features import *
1111
import os
12-
from os.path import basename, dirname, join, normpath, relpath, splitext
12+
from os.path import basename, dirname, join, normpath, relpath, splitext, isfile
1313
from pathlib import PureWindowsPath
1414
import glob
1515
import tla_utils
@@ -104,17 +104,14 @@ def generate_new_manifest(examples_root, spec_path, spec_name, parser, queries):
104104

105105
# Integrate human-written info from existing manifest.json
106106

107-
def find_corresponding_spec(old_manifest, new_spec):
108-
specs = [
109-
spec for spec in old_manifest['specifications']
110-
if spec['path'] == new_spec['path']
111-
]
112-
return specs[0] if any(specs) else None
107+
def get_old_manifest(spec_path):
108+
old_manifest_path = join(spec_path, 'manifest.json')
109+
return tla_utils.load_json(old_manifest_path) if isfile(old_manifest_path) else None
113110

114-
def integrate_spec_info(old_spec, new_spec):
111+
def integrate_spec_info(old_manifest, new_spec):
115112
fields = ['title', 'description', 'authors', 'sources', 'tags']
116113
for field in fields:
117-
new_spec[field] = old_spec[field]
114+
new_spec[field] = old_manifest[field]
118115

119116
def find_corresponding_module(old_module, new_spec):
120117
modules = [
@@ -142,9 +139,10 @@ def integrate_model_info(old_model, new_model):
142139
new_model[field] = old_model[field]
143140

144141
def integrate_old_manifest_into_new(old_manifest, new_spec):
145-
old_spec = find_corresponding_spec(old_manifest, new_spec)
146-
integrate_spec_info(old_spec, new_spec)
147-
for old_module in old_spec['modules']:
142+
if old_manifest is None:
143+
return
144+
integrate_spec_info(old_manifest, new_spec)
145+
for old_module in old_manifest['modules']:
148146
new_module = find_corresponding_module(old_module, new_spec)
149147
if new_module is None:
150148
continue
@@ -156,22 +154,20 @@ def integrate_old_manifest_into_new(old_manifest, new_spec):
156154
integrate_model_info(old_model, new_model)
157155

158156
if __name__ == '__main__':
159-
parser = ArgumentParser(description='Generates a new manifest.json derived from files in the repo.')
160-
parser.add_argument('--manifest_path', help='Path to the current tlaplus/examples manifest.json file', default='manifest.json')
157+
parser = ArgumentParser(description='Generates new manifest.json files derived from files in the repo.')
161158
parser.add_argument('--ci_ignore_path', help='Path to the CI ignore file', default='.ciignore')
162159
args = parser.parse_args()
163160

164-
manifest_path = normpath(args.manifest_path)
165-
examples_root = dirname(manifest_path)
166161
ci_ignore_path = normpath(args.ci_ignore_path)
162+
examples_root = dirname(ci_ignore_path)
167163
ignored_dirs = tla_utils.get_ignored_dirs(ci_ignore_path)
168164

169165
TLAPLUS_LANGUAGE = Language(tree_sitter_tlaplus.language())
170166
parser = Parser(TLAPLUS_LANGUAGE)
171167
queries = build_queries(TLAPLUS_LANGUAGE)
172168

173-
old_manifest = tla_utils.load_json(manifest_path)
174169
for (spec_path, spec_name) in get_spec_dirs(examples_root, ignored_dirs):
170+
old_manifest = get_old_manifest(spec_path)
175171
new_manifest = generate_new_manifest(examples_root, spec_path, spec_name, parser, queries)
176172
integrate_old_manifest_into_new(old_manifest, new_manifest)
177173
tla_utils.write_json(new_manifest, join(spec_path, 'manifest.json'))

.github/scripts/record_model_state_space.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
parser.add_argument('--tools_jar_path', help='Path to the tla2tools.jar file', required=True)
1414
parser.add_argument('--tlapm_lib_path', help='Path to the TLA+ proof manager module directory; .tla files should be in this directory', required=True)
1515
parser.add_argument('--community_modules_jar_path', help='Path to the CommunityModules-deps.jar file', required=True)
16-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
16+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
1717
parser.add_argument('--skip', nargs='+', help='Space-separated list of models to skip checking', required=False, default=[])
1818
parser.add_argument('--only', nargs='+', help='If provided, only check models in this space-separated list', required=False, default=[])
1919
parser.add_argument('--enable_assertions', help='Enable Java assertions (pass -enableassertions to JVM)', action='store_true')
@@ -25,8 +25,7 @@
2525
tools_jar_path = normpath(args.tools_jar_path)
2626
tlapm_lib_path = normpath(args.tlapm_lib_path)
2727
community_jar_path = normpath(args.community_modules_jar_path)
28-
manifest_path = normpath(args.manifest_path)
29-
examples_root = dirname(manifest_path)
28+
examples_root = args.examples_root
3029
skip_models = args.skip
3130
only_models = args.only
3231
run_all = args.all
@@ -77,11 +76,11 @@ def check_model(module, model):
7776
return False
7877

7978
# Ensure longest-running modules go first
80-
manifest = tla_utils.load_json(manifest_path)
79+
manifest = tla_utils.load_all_manifests(examples_root)
8180
small_models = sorted(
8281
[
83-
(module, model, tla_utils.parse_timespan(model['runtime']))
84-
for spec in manifest['specifications']
82+
(spec, module, model, tla_utils.parse_timespan(model['runtime']))
83+
for spec in manifest
8584
for module in spec['modules']
8685
for model in module['models']
8786
if model['size'] == 'small'
@@ -105,7 +104,8 @@ def check_model(module, model):
105104
for path in skip_models:
106105
logging.info(f'Skipping {path}')
107106

108-
for module, model, _ in small_models:
107+
for spec, module, model, _ in small_models:
108+
manifest_path = join(spec['path'], 'manifest.json')
109109
success = check_model(module, model)
110110
if not success:
111111
exit(1)

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ jobs:
161161
- name: Smoke-test manifest generation script
162162
run: |
163163
python $SCRIPT_DIR/generate_manifest.py \
164-
--examples_root . \
165164
--ci_ignore_path .ciignore
166165
git diff -a
167166
- name: Smoke-test state space script

0 commit comments

Comments
 (0)