uooon commited on
Commit
5355b4b
·
verified ·
1 Parent(s): d66bb85

Remove development tests from dataset distribution

Browse files
MANIFEST.in CHANGED
@@ -1,3 +1,2 @@
1
  include README.zh-CN.md constraints-tested.txt
2
  recursive-include tools *.py
3
- recursive-include tests *.py
 
1
  include README.zh-CN.md constraints-tested.txt
2
  recursive-include tools *.py
 
tests/test_distribution.py DELETED
@@ -1,63 +0,0 @@
1
- """Portable distribution contracts; no access to original source directories."""
2
- import json
3
- from pathlib import Path
4
-
5
- import pytest
6
-
7
- from geomotion.runtime import ROOT
8
-
9
-
10
- def test_registered_suite_and_packaged_demonstrations(monkeypatch, tmp_path):
11
- monkeypatch.setenv('XDG_CACHE_HOME', str(tmp_path))
12
- import geomotion
13
- suite = geomotion.get_suite()
14
- from libero.libero.benchmark import get_benchmark_dict
15
- assert set(get_benchmark_dict()) == {'libero_rp'}
16
- assert suite.n_tasks == 36
17
- expected = json.loads((ROOT / 'libero_rotation_planning/benchmark/task_manifest.json').read_text())
18
- assert suite.get_task_names() == [t['name'] for t in expected]
19
- assert [suite.get_task(i).language for i in range(suite.n_tasks)] == [t['language'] for t in expected]
20
- assert suite.get_num_tasks() == len(expected)
21
- suite.set_task_embs(list(range(len(expected))))
22
- assert suite.get_task_emb(3) == 3
23
- assert Path(suite.get_task_demonstration(0)).is_file()
24
- with pytest.raises(FileNotFoundError):
25
- suite.get_task_demonstration(1)
26
- with pytest.raises(ValueError):
27
- type(suite)(task_order_index=1)
28
-
29
-
30
- def test_factory_rejects_invalid_task():
31
- import geomotion
32
- for task in (-1, 36, True, '0'):
33
- with pytest.raises(ValueError, match='task_id'):
34
- geomotion.make_env(task)
35
-
36
-
37
- def test_runtime_resources_do_not_escape_installation():
38
- for package in ('geomotion', 'libero', 'libero_rotation_planning'):
39
- for path in (ROOT / package).rglob('*'):
40
- assert path.resolve().is_relative_to(ROOT)
41
- assert not path.is_symlink()
42
-
43
-
44
- def test_export_rejects_missing_experts_before_writing(tmp_path):
45
- from geomotion.cli import main
46
- destination = tmp_path / 'references'
47
- with pytest.raises(SystemExit) as error:
48
- main(['export-references', '--ids', '4,12', '--output', str(destination)])
49
- assert error.value.code == 1
50
- assert not destination.exists()
51
-
52
-
53
- def test_export_preserves_existing_output_before_starting_batch(tmp_path):
54
- from geomotion.cli import main
55
- existing = tmp_path / 'task_004'
56
- existing.mkdir()
57
- sentinel = existing / 'keep.txt'
58
- sentinel.write_text('keep this reference')
59
- with pytest.raises(SystemExit) as error:
60
- main(['export-references', '--ids', '0,4', '--output', str(tmp_path)])
61
- assert error.value.code == 1
62
- assert sentinel.read_text() == 'keep this reference'
63
- assert not (tmp_path / 'task_000').exists()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tests/test_task_metadata.py DELETED
@@ -1,78 +0,0 @@
1
- """Task definitions, runtime defaults, and packaged demonstrations agree."""
2
- import inspect
3
- import json
4
- import re
5
- import subprocess
6
- import sys
7
-
8
- import h5py
9
- import numpy as np
10
-
11
- import geomotion
12
- from geomotion.runtime import ROOT, RESOURCES, evaluation_protocol, reference_manifest, task_manifest
13
-
14
-
15
- def test_task_definitions_and_runtime_defaults():
16
- tasks = task_manifest()
17
- protocol = evaluation_protocol()
18
- families = json.loads((RESOURCES / 'task_families.json').read_text())
19
- task_ids = [task['id'] for task in tasks]
20
- assert task_ids == list(range(36)) == protocol['task_ids']
21
- assert len({task['name'] for task in tasks}) == len(tasks)
22
- assert len(families) == 9
23
- assert sorted(i for family in families for i in family['task_ids']) == task_ids
24
- for family in families:
25
- assert family['count'] == len(family['task_ids'])
26
- parameters = inspect.signature(geomotion.make_env).parameters
27
- assert parameters['image_size'].default == protocol['camera_resolution'][0]
28
- assert parameters['max_steps'].default == protocol['max_episode_steps']
29
- assert geomotion.__version__ == protocol['version']
30
- assert protocol['task_order_index'] == 0
31
- assert protocol['initial_state_indices'] == [0]
32
- assert protocol['action_dimension'] == 7
33
- assert protocol['action_range'] == [-1, 1]
34
- extension = ROOT / 'libero_rotation_planning'
35
- for task in tasks:
36
- name = task['name']
37
- bddl = extension / 'bddl_files' / protocol['suite'] / (name + '.bddl')
38
- language = re.search(r'\(:language\s+([^)]*)\)', bddl.read_text())
39
- assert language and ' '.join(language[1].split()) == task['language']
40
- assert (extension / 'init_files' / protocol['suite'] / (name + '.pruned_init')).is_file()
41
- assert (extension / 'scene_specs' / (name + '.json')).is_file()
42
-
43
-
44
- def test_demonstrations_match_tasks_and_initial_states():
45
- tasks = task_manifest()
46
- protocol = evaluation_protocol()
47
- rows = reference_manifest()['references']
48
- assert [row['id'] for row in rows] == [0, 4, 8, 26, 28, 34]
49
- suite = geomotion.get_suite()
50
- folder = RESOURCES / 'expert_reference'
51
- for row in rows:
52
- task = tasks[row['id']]
53
- assert all(row[key] == task[key] for key in ('name', 'language'))
54
- assert row['control_hz'] == protocol['control_frequency_hz']
55
- for item in row['files'].values():
56
- path = folder / item['path']
57
- assert path.resolve().is_relative_to(folder.resolve()) and path.is_file()
58
- with h5py.File(folder / row['files']['dataset']['path'], 'r') as source:
59
- data = source['data/demo_0']
60
- assert data['actions'].shape == (row['num_samples'], 7)
61
- assert len(data['states']) == row['num_samples']
62
- np.testing.assert_allclose(data['states'][0],
63
- suite.get_task_init_states(row['id'])[0], rtol=0, atol=1e-12)
64
-
65
-
66
- def test_benchmark_import_does_not_shuffle_global_random_state():
67
- subprocess.run([sys.executable, '-c', '''
68
- import geomotion
69
- geomotion.get_suite()
70
- import importlib, random, sys
71
- from libero.libero import benchmark
72
- state = random.getstate()
73
- importlib.reload(benchmark)
74
- assert random.getstate() == state
75
- assert 'libero.libero.benchmark.libero_suite_task_map' not in sys.modules
76
- assert not hasattr(benchmark, 'LIBERO_SPATIAL')
77
- '''], check=True, cwd=ROOT, capture_output=True, text=True)
78
-