Repository navigation
docs(examples): three user examples that open a file, list its elements and export it, run in CI (#872) - #904
Conversation
…ts and export it, run in CI (#872)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87bca055b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…s, the examples take any path, and CI runs them on Einhoven too
|
A correction to my reply on the The change stays as it is. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f47c22de3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .next() | ||
| .map_or_else(|| PathBuf::from(FIXTURE), PathBuf::from); | ||
| let out = args.next().map_or_else( | ||
| || std::env::temp_dir().join(format!("rvt-basics-export-{}", std::process::id())), |
There was a problem hiding this comment.
Create the default export directory securely
On a shared Unix host, this PID-only path is predictable and can already exist: another user can pre-create /tmp/rvt-basics-export-<pid> with a symlink such as model.ifc, after which create_dir_all succeeds and std::fs::write follows the symlink, truncating a file writable by the victim; ordinary PID reuse can also overwrite an earlier export. The follow-up moved the files out of the temp root, but the fresh evidence here is that the replacement is not actually unique or safely created, so use a securely randomized, atomically created temporary directory.
Useful? React with 👍 / 👎.
| use rvt::ifc::RvtDocExporter; | ||
| use rvt::ifc::entities::IfcEntity; | ||
|
|
||
| const FIXTURE: &str = "corpus/tier1/architectural-2024/architectural-2024.rvt"; |
There was a problem hiding this comment.
Resolve the fallback fixture from the manifest directory
When any no-argument example is launched from examples/, another workspace subdirectory, or externally with Cargo's documented --manifest-path <PATH> option, the child retains the caller's working directory and this relative path no longer points at the shipped fixture. All three examples use the same fallback while CI always invokes them from the repository root, so their advertised no-argument mode fails in those supported invocation contexts; construct the path from env!("CARGO_MANIFEST_DIR") instead.
Useful? React with 👍 / 👎.
Summary
Three user examples,
basics_inspect,basics_elementsandbasics_export, that open a Revit file, list its elements and export it. Each runs on the committed synthetic project without arguments, and CI runs all three. Part 2 of #872 ("examples/ separates user examples from research probes, and the README links the user examples").Motivation
#872, criterion S3 of
docs/release-1.0-criteria.md:examples/held about 180 research programs and no example of ordinary use.Changes
examples/basics_inspect.rs: release, title and last save (metadata::read_metadata), build, stream count and schema class count (RevitFile::summarize_strict).examples/basics_elements.rs:walker::iter_elements, the first five with ElementId and provenance, then a count per class and a total.examples/basics_export.rs:RvtDocExporter::export_with_diagnostics, thenmodel.ifc(write_step),model.glb(gltf::model_to_glb),elements.csv(schedule_csv::elements_csv) anddiagnostics.json, into a directory given as the second argument (the system temp directory by default).examples/README.md: the naming.basics_*are the user examples;probe_*and the rest are research and uservt::research.README.md: the "Use the Rust library" row and the Library surface section link the examples.ci.yml: a "Run the user examples" step after the real-file verification, Linux stable only. It runs all three and fails ifbasics_exportleaves any of its four files missing or empty.tools/check-local.shmirrors it.CHANGELOG.md: an[Unreleased]entry.The examples use only stable modules, so they keep working without
unstable-research. They call the same entry points as the doctests in #900. That PR's run 39952498538 showssummarize_strict,iter_elementsandexport_with_diagnosticssucceed on the fixture.Testing
tools/check-local.shpasses: not run locally (compute stays on CI runners). CI's build compiles every example on Linux, and the new step runs them.corpus/tier1/architectural-2024/architectural-2024.rvt, the synthetic fixture. Nothing about extraction changes.Audit-honesty checklist
Legal and contribution hygiene