Skip to content

Commit cad798e

Browse files
committed
Manifest: remove path, title, and description fields
In furtherance of tlaplus#171 The path property is now inherent in the location of the manifest.json file, the README.md table can be the source of truth for the spec title, and the spec description can live in the directory-specific README.md file. Signed-off-by: Andrew Helwer <ahelwer@pm.me>
1 parent b209722 commit cad798e

92 files changed

Lines changed: 35 additions & 292 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/scripts/check_manifest_features.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,10 @@ def check_features(parser, queries, manifest, examples_root):
154154
Validates every field of the manifest that can be validated.
155155
"""
156156
success = True
157-
for spec in manifest:
158-
if spec['title'] == '':
159-
success = False
160-
logging.error(f'Spec {spec["path"]} does not have a title')
161-
if spec['description'] == '':
162-
success = False
163-
logging.error(f'Spec {spec["path"]} does not have a description')
157+
for path, spec in manifest:
164158
if not any(spec['authors']):
165159
success = False
166-
logging.error(f'Spec {spec["path"]} does not have any listed authors')
160+
logging.error(f'Spec {path} does not have any listed authors')
167161
for module in spec['modules']:
168162
module_path = module['path']
169163
tree, text, parse_err = tla_utils.parse_module(examples_root, parser, module_path)

.github/scripts/check_manifest_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
examples_root = dirname(ci_ignore_path)
2020
manifest = tla_utils.load_all_manifests(examples_root)
2121

22-
module_lists = [spec["modules"] for spec in manifest]
22+
module_lists = [spec["modules"] for path, spec in manifest]
2323
modules = [module for module_list in module_lists for module in module_list]
2424
model_lists = [module["models"] for module in modules]
2525

.github/scripts/check_manifest_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
examples_root = dirname(args.schema_path)
2222
schema = tla_utils.load_json(normpath(args.schema_path))
2323
failures = []
24-
for manifest in tla_utils.load_all_manifests(examples_root):
25-
manifest_path = join(manifest['path'], "manifest.json")
24+
for path, manifest in tla_utils.load_all_manifests(examples_root):
25+
manifest_path = join(path, 'manifest.json')
2626
try:
2727
validate(instance=manifest, schema=schema)
2828
except ValidationError as error:

.github/scripts/check_markdown_table.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ def from_markdown(record):
5858
record
5959
)
6060

61-
def from_json(spec):
61+
def from_json(path, spec):
6262
'''
6363
Transforms JSON from the manifest into a normalized form.
6464
'''
6565
return TableRow(
66-
spec['title'],
67-
spec['path'],
66+
'',
67+
path,
6868
set(spec['authors']),
6969
'beginner' in spec['tags'],
7070
any([module for module in spec['modules'] if 'proof' in module['features']]),
@@ -87,7 +87,7 @@ def from_json(spec):
8787
spec_table = next((child for child in readme.children if isinstance(child, Table)))
8888

8989
table_specs = dict([(record.path, record) for record in [from_markdown(node) for node in spec_table.children]])
90-
manifest_specs = dict([(record.path, record) for record in [from_json(spec) for spec in manifest]])
90+
manifest_specs = dict([(record.path, record) for record in [from_json(path, spec) for path, spec in manifest]])
9191

9292
# Checks that set of specs in manifest and table are equivalent
9393
success = True
@@ -107,18 +107,6 @@ def from_json(spec):
107107
if path in table_specs
108108
]
109109

110-
# Ensure spec names are identical
111-
different_names = [
112-
(manifest_spec.path, manifest_spec.name, table_spec.name)
113-
for (manifest_spec, table_spec) in specs
114-
if manifest_spec.name != table_spec.name
115-
]
116-
if any(different_names):
117-
success = False
118-
print('ERROR: spec names in README.md table differ from manifest.json:')
119-
for path, json, md in different_names:
120-
print(f'Spec {path} has name {json} in manifest and {md} in README')
121-
122110
# Ensure spec authors are identical
123111
different_authors = [
124112
(manifest_spec.path, manifest_spec.authors, table_spec.authors)

.github/scripts/check_proofs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
proof_module_paths = [
2929
module['path']
30-
for spec in manifest
30+
for path, spec in manifest
3131
for module in spec['modules']
3232
if 'proof' in module['features']
3333
and module['path'] not in skip_modules

.github/scripts/check_small_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def check_model(module, model, expected_runtime):
8989
small_models = sorted(
9090
[
9191
(module, model, tla_utils.parse_timespan(model['runtime']))
92-
for spec in manifest
92+
for path, spec in manifest
9393
for module in spec['modules']
9494
for model in module['models']
9595
if model['size'] == 'small'

.github/scripts/generate_manifest.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@
1010
from check_manifest_features import *
1111
import os
1212
from os.path import basename, dirname, join, normpath, relpath, splitext, isfile
13-
from pathlib import PureWindowsPath
1413
import glob
1514
import tla_utils
1615
import tree_sitter_tlaplus
1716
from tree_sitter import Language, Parser
1817

19-
def to_posix(path):
20-
"""
21-
Converts paths to normalized Posix format.
22-
https://stackoverflow.com/q/75291812/2852699
23-
"""
24-
return PureWindowsPath(normpath(path)).as_posix()
25-
2618
def get_spec_dirs(examples_root, ignored_dirs):
2719
"""
2820
Get all directories under the specifications dir, sorted alphabetically.
@@ -74,21 +66,18 @@ def generate_new_manifest(examples_root, spec_path, spec_name, parser, queries):
7466
Generate new manifest.json file for a given specification directory.
7567
"""
7668
return {
77-
'path': to_posix(spec_path),
78-
'title': spec_name,
79-
'description': '',
8069
'sources': [],
8170
'authors': [],
8271
'tags': [],
8372
'modules': [
8473
{
85-
'path': to_posix(tla_path),
74+
'path': tla_utils.to_posix(tla_path),
8675
'communityDependencies': sorted(list(get_community_module_imports(examples_root, parser, tla_path, queries))),
8776
'tlaLanguageVersion': 2,
8877
'features': sorted(list(get_module_features(examples_root, tla_path, parser, queries))),
8978
'models': [
9079
{
91-
'path': to_posix(cfg_path),
80+
'path': tla_utils.to_posix(cfg_path),
9281
'runtime': 'unknown',
9382
'size': 'unknown',
9483
'mode': 'exhaustive search',
@@ -108,14 +97,14 @@ def get_old_manifest(spec_path):
10897
return tla_utils.load_json(old_manifest_path) if isfile(old_manifest_path) else None
10998

11099
def integrate_spec_info(old_manifest, new_spec):
111-
fields = ['title', 'description', 'authors', 'sources', 'tags']
100+
fields = ['authors', 'sources', 'tags']
112101
for field in fields:
113102
new_spec[field] = old_manifest[field]
114103

115104
def find_corresponding_module(old_module, new_spec):
116105
modules = [
117106
module for module in new_spec['modules']
118-
if to_posix(module['path']) == to_posix(old_module['path'])
107+
if tla_utils.to_posix(module['path']) == tla_utils.to_posix(old_module['path'])
119108
]
120109
return modules[0] if any(modules) else None
121110

@@ -127,7 +116,7 @@ def integrate_module_info(old_module, new_module):
127116
def find_corresponding_model(old_model, new_module):
128117
models = [
129118
model for model in new_module['models']
130-
if to_posix(model['path']) == to_posix(old_model['path'])
119+
if tla_utils.to_posix(model['path']) == tla_utils.to_posix(old_model['path'])
131120
]
132121
return models[0] if any(models) else None
133122

.github/scripts/parse_modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def parse_module(path):
6868
# List of all modules to parse and whether they should use TLAPS imports
6969
modules = [
7070
tla_utils.from_cwd(examples_root, module['path'])
71-
for spec in manifest
71+
for path, spec in manifest
7272
for module in spec['modules']
7373
if module['path'] not in skip_modules
7474
and (only_modules == [] or module['path'] in only_modules)

.github/scripts/record_model_state_space.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def check_model(module, model):
7979
small_models = sorted(
8080
[
8181
(spec, module, model, tla_utils.parse_timespan(model['runtime']))
82-
for spec in manifest
82+
for path, spec in manifest
8383
for module in spec['modules']
8484
for model in module['models']
8585
if model['size'] == 'small'

.github/scripts/smoke_test_large_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def check_model(module, model):
8282

8383
large_models = [
8484
(module, model)
85-
for spec in manifest
85+
for path, spec in manifest
8686
for module in spec['modules']
8787
for model in module['models']
8888
if model['size'] != 'small'

0 commit comments

Comments
 (0)