plaid.viewer.services.paraview_artifact_service¶
plaid.viewer.services.paraview_artifact_service
¶
Produce ParaView-readable artifacts from PLAID samples.
This module is the one place in PLAID that writes CGNS files on disk. It
delegates the actual CGNS export to PLAID (Sample.save_to_dir writes one
CGNS per timestep under meshes/), then adds:
- A
.cgns.seriessidecar JSON file that ParaView'svtkCGNSReader/vtkCGNSFileSeriesReaderunderstands for multi-timestep samples. - A deterministic artifact id derived from a SHA256 cache key so the same inputs always resolve to the same folder.
- An optional
scene.pvsmplaceholder for future preset work. - A
metadata.jsondescribing the artifact.
plaid.viewer.services.paraview_artifact_service.ParaviewArtifactService
¶
ParaviewArtifactService(
dataset_service,
cache_root,
*,
export_version=EXPORT_VERSION,
extra_cache_key_fields=None,
)
Create and look up ParaView-readable artifacts in a cache directory.
Parameters:
-
dataset_service(PlaidDatasetService) –Used to load :class:
plaid.Sampleinstances. -
cache_root(Path) –Root of the artifact cache. Usually owned by a :class:
plaid.viewer.cache.CacheRootinstance. -
export_version(str, default:EXPORT_VERSION) –Opaque string included in the cache key. Bump this whenever the export logic changes in a backwards-incompatible way.
-
extra_cache_key_fields(dict[str, str] | None, default:None) –Extra fields to mix into the cache key (for example to invalidate artifacts when a preset template changes).
Source code in plaid/viewer/services/paraview_artifact_service.py
plaid.viewer.services.paraview_artifact_service.ParaviewArtifactService.ensure_artifact
¶
Return a :class:ParaviewArtifact for ref, creating it if needed.
The cache holds at most one artifact: any previously-ensured artifact
whose layout root differs from ref's is removed from disk.
Source code in plaid/viewer/services/paraview_artifact_service.py
plaid.viewer.services.paraview_artifact_service.ParaviewArtifactService.get
¶
Return a previously-created artifact by id.
Raises:
-
KeyError–If no artifact with this id has been created.
Source code in plaid/viewer/services/paraview_artifact_service.py
plaid.viewer.services.paraview_artifact_service.ensure_paraview_artifact
¶
Functional wrapper around :meth:ParaviewArtifactService.ensure_artifact.