Progress Facility

About

The Progress Facility makes allows reporting of the overall completion percentage of a given Omniverse Farm job.

This can be particularly helpful for Users wishing to have at-a-glance information on the overall status of a job, and to derive an approximate time of completion. This information is surfaced to Users through the Farm Queue Dashboard, where progress can be monitored from the list of tasks, or by inspecting the detailed view of a specific task, where timestamped progress information will be logged.

Configuration

The Progress Facility can be accessed from a Kit Service by first registering the Facility’s instance on the Service’s router:

extension.py
 1import omni.ext
 2
 3from omni.services.core import main
 4from omni.services.facilities.monitoring.progress.facilities import ProgressFacility
 5
 6from .services.sample import router
 7
 8
 9class SampleProgressFacilityExtension(omni.ext.IExt):
10    """Sample Extension illustrating usage of the Progress Facility."""
11
12    def on_startup(self) -> None:
13        router.register_facility(name="progress", facility_inst=ProgressFacility())
14        main.register_router(router=router, prefix="/sample-progress", tags=["example"])
15
16    def on_shutdown(self) -> None:
17        main.deregister_router(router=router, prefix="/sample-progress")

Usage

Once configured, the Progress Facility then becomes available to the Service’s endpoints via dependency injection:

services/sample.py
 1import asyncio
 2
 3from omni.services.core import routers
 4from omni.services.facilities.monitoring.progress.facilities import ProgressFacility
 5
 6router = routers.ServiceAPIRouter()
 7
 8
 9@router.post("/sample-endpoint")
10async def sample(
11    progress_facility: ProgressFacility = router.get_facility("progress"),
12):
13    # For demonstration purposes, we mimic a long-running operation by reporting progress every second
14    # for a total of 60 seconds. In a real-world scenario, progress would be reported as needed by calling
15    # `progress_facility.set_progress()` when appropriate, so the information could be surfaced to the User.
16    TOTAL_STEP_COUNT = 60
17
18    for step_number in range(TOTAL_STEP_COUNT):
19        progress_facility.set_progress(
20            # Index of the current step in the overall progress:
21            current_step_index=step_number,
22            # Overall number of steps in the progress:
23            total_step_count=TOTAL_STEP_COUNT,
24            # Optional status message providing additional information about the current progress of the task:
25            status_message=f"Completed step {step_number} of {TOTAL_STEP_COUNT}",
26        )
27
28        await asyncio.sleep(delay=1.0)  # Wait a moment to mimic a long operation.
29
30    return {"success": True}

Implementation References

For examples of the Progress Facility being used in the Omniverse Farm ecosystem, consult the following extensions:

  • omni.services.collect: Bulk collection of USD assets

  • omni.services.render: Rendering service for USD stages

  • omni.services.thumbnails.mdl: Rendering service for MDL thumbnails