Skip to content

Commit b87603e

Browse files
committed
Name the declared checkpoints for what they are
"Auxiliary" ranked these files below the policy and did not generalise: any component can declare a run artifact, and the policy is not special among them. The discovery and path helpers, their parameter, and the collect locals now say declared.
1 parent 18689b2 commit b87603e

4 files changed

Lines changed: 29 additions & 29 deletions

File tree

scripts/tools/train_and_publish_checkpoints.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
from isaaclab_rl.utils.pretrained_checkpoint import (
8484
WORKFLOW_EXPERIMENT_NAME_VARIABLE,
8585
WORKFLOWS,
86-
get_auxiliary_checkpoint_path,
87-
get_auxiliary_checkpoints,
86+
get_declared_checkpoint_path,
87+
get_declared_checkpoints,
8888
get_latest_job_run_path,
8989
get_pretrained_checkpoint_backend_names,
9090
get_pretrained_checkpoint_filename,
@@ -119,7 +119,7 @@ class CheckpointJob:
119119
render_selector: str | None = None
120120
agent: str | None = None
121121
algorithm: str | None = None
122-
auxiliary_checkpoints: tuple[Checkpoint, ...] = ()
122+
declared_checkpoints: tuple[Checkpoint, ...] = ()
123123
"""Run artifacts the task publishes beside its policy."""
124124

125125
@property
@@ -365,7 +365,7 @@ def _build_core_jobs(args: argparse.Namespace) -> list[CheckpointJob]:
365365
render_selector=render_selector,
366366
agent=agent,
367367
algorithm=algorithm,
368-
auxiliary_checkpoints=tuple(get_auxiliary_checkpoints(env_cfg)),
368+
declared_checkpoints=tuple(get_declared_checkpoints(env_cfg)),
369369
)
370370
)
371371
return jobs
@@ -547,14 +547,14 @@ def collect_pretrained_checkpoint(job: CheckpointJob, output_dir: str, dry_run:
547547
os.makedirs(os.path.dirname(destination), exist_ok=True)
548548
shutil.copy2(source_path, destination)
549549
run_path = get_latest_job_run_path(job.workflow, job.task_name, job.physics_backend, job.render_backend)
550-
for checkpoint in job.auxiliary_checkpoints:
551-
aux_source = checkpoint.find_in(run_path)
552-
if aux_source is None:
550+
for checkpoint in job.declared_checkpoints:
551+
declared_source = checkpoint.find_in(run_path)
552+
if declared_source is None:
553553
print(f"No {checkpoint.name} checkpoint matched {checkpoint.run_glob!r} for {job.job_id}")
554554
continue
555-
aux_destination = get_auxiliary_checkpoint_path(destination, job.workflow, checkpoint)
556-
print(f"Collecting {aux_source} -> {aux_destination}")
557-
shutil.copy2(aux_source, aux_destination)
555+
declared_destination = get_declared_checkpoint_path(destination, job.workflow, checkpoint)
556+
print(f"Collecting {declared_source} -> {declared_destination}")
557+
shutil.copy2(declared_source, declared_destination)
558558
return destination
559559

560560

@@ -659,12 +659,12 @@ def publish_pretrained_checkpoint(job: CheckpointJob, args: argparse.Namespace)
659659
)
660660
publish_path = posixpath.join(args.publish_root.rstrip("/"), job.workflow, filename)
661661
uploads = [(local_path, publish_path)]
662-
for checkpoint in job.auxiliary_checkpoints:
663-
local_auxiliary = get_auxiliary_checkpoint_path(local_path, job.workflow, checkpoint)
664-
if not os.path.isfile(local_auxiliary):
662+
for checkpoint in job.declared_checkpoints:
663+
local_declared = get_declared_checkpoint_path(local_path, job.workflow, checkpoint)
664+
if not os.path.isfile(local_declared):
665665
print(f"Skipping the {checkpoint.name} checkpoint for {job.job_id}; it was not collected")
666666
continue
667-
uploads.append((local_auxiliary, get_auxiliary_checkpoint_path(publish_path, job.workflow, checkpoint)))
667+
uploads.append((local_declared, get_declared_checkpoint_path(publish_path, job.workflow, checkpoint)))
668668
for source, destination in uploads:
669669
print(f"Publishing {source} -> {destination}")
670670
if args.dry_run:

source/isaaclab_rl/isaaclab_rl/utils/pretrained_checkpoint.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_published_pretrained_checkpoint_path(
221221
return posixpath.join(*path_parts, filename)
222222

223223

224-
def get_auxiliary_checkpoints(
224+
def get_declared_checkpoints(
225225
env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg,
226226
) -> list[Checkpoint]:
227227
"""Return the run artifacts a task publishes beside its policy checkpoint.
@@ -245,8 +245,8 @@ def get_auxiliary_checkpoints(
245245
return list(unique.values())
246246

247247

248-
def get_auxiliary_checkpoint_path(checkpoint_path: str, workflow: str, checkpoint: Checkpoint) -> str:
249-
"""Return where an auxiliary checkpoint lives beside a policy checkpoint path.
248+
def get_declared_checkpoint_path(checkpoint_path: str, workflow: str, checkpoint: Checkpoint) -> str:
249+
"""Return where a declared checkpoint lives beside a policy checkpoint path.
250250
251251
Args:
252252
checkpoint_path: Local or published path of the policy checkpoint.
@@ -292,11 +292,11 @@ def get_published_pretrained_checkpoint(
292292
Returns:
293293
The path.
294294
"""
295-
auxiliary_checkpoints: Sequence[Checkpoint] = ()
295+
declared_checkpoints: Sequence[Checkpoint] = ()
296296
if env_cfg is not None:
297297
if physics_backend is None and render_backend is None:
298298
physics_backend, render_backend = get_pretrained_checkpoint_backend_names(env_cfg)
299-
auxiliary_checkpoints = get_auxiliary_checkpoints(env_cfg)
299+
declared_checkpoints = get_declared_checkpoints(env_cfg)
300300
ov_path = get_published_pretrained_checkpoint_path(workflow, task_name, physics_backend, render_backend)
301301
# one cache directory per published checkpoint: play treats it as the run log directory and
302302
# writes videos, exported policies, and additional checkpoints into it
@@ -310,8 +310,8 @@ def get_published_pretrained_checkpoint(
310310
if resume_path is None:
311311
print("A pre-trained checkpoint is currently unavailable for this task.")
312312
return None
313-
for checkpoint in auxiliary_checkpoints:
314-
_fetch(get_auxiliary_checkpoint_path(ov_path, workflow, checkpoint), download_dir)
313+
for checkpoint in declared_checkpoints:
314+
_fetch(get_declared_checkpoint_path(ov_path, workflow, checkpoint), download_dir)
315315
return resume_path
316316

317317

source/isaaclab_rl/test/test_pretrained_checkpoint.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,19 @@ def test_get_published_pretrained_checkpoint_tolerates_no_feature_extractor(
257257
),
258258
],
259259
)
260-
def test_get_auxiliary_checkpoint_path_keeps_the_declared_extension(checkpoint, expected):
261-
"""Test that a published auxiliary keeps the extension the component declared."""
262-
path = pretrained_checkpoint.get_auxiliary_checkpoint_path(
260+
def test_get_declared_checkpoint_path_keeps_the_declared_extension(checkpoint, expected):
261+
"""Test that a published checkpoint keeps the extension the component declared."""
262+
path = pretrained_checkpoint.get_declared_checkpoint_path(
263263
"/logs/Isaac-Cartpole_physx_none_rsl_rl.pt", "rsl_rl", checkpoint
264264
)
265265
assert path == expected
266266

267267

268-
def test_get_auxiliary_checkpoints_discovers_nested_component_configs():
268+
def test_get_declared_checkpoints_discovers_nested_component_configs():
269269
"""Test that a component config declaring a checkpoint is found without the task listing it."""
270-
assert pretrained_checkpoint.get_auxiliary_checkpoints(_EnvCfg()) == []
270+
assert pretrained_checkpoint.get_declared_checkpoints(_EnvCfg()) == []
271271

272-
found = pretrained_checkpoint.get_auxiliary_checkpoints(_EnvCfg(extractor=_ExtractorCfg()))
272+
found = pretrained_checkpoint.get_declared_checkpoints(_EnvCfg(extractor=_ExtractorCfg()))
273273

274274
# only run artifacts are published beside the policy; URL weights are the component's to fetch
275275
assert [(c.name, c.run_glob) for c in found] == [("feature_extractor", "cnn_*.pth")]

source/isaaclab_tasks/test/core/test_shadow_hand_camera_presets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from isaaclab.renderers import RendererCfg
3333
from isaaclab.sensors import CameraCfg
3434

35-
from isaaclab_rl.utils.pretrained_checkpoint import get_auxiliary_checkpoints
35+
from isaaclab_rl.utils.pretrained_checkpoint import get_declared_checkpoints
3636

3737
from isaaclab_tasks.core.reorient.config.shadow_hand.feature_extractor import FeatureExtractor, FeatureExtractorCfg
3838
from isaaclab_tasks.core.reorient.config.shadow_hand.shadow_hand_camera_manager_env_cfg import (
@@ -307,5 +307,5 @@ def test_camera_task_publishes_the_feature_extractor_checkpoint():
307307
expected = FeatureExtractorCfg().checkpoint
308308

309309
for env_cfg in (ShadowHandCameraEnvCfg(), ShadowHandCameraManagerEnvCfg()):
310-
(found,) = get_auxiliary_checkpoints(env_cfg)
310+
(found,) = get_declared_checkpoints(env_cfg)
311311
assert (found.name, found.run_glob) == (expected.name, expected.run_glob)

0 commit comments

Comments
 (0)