Skip to content

[graph] Add possibility to set a specific cacheDir in the mg scene#3077

Merged
cbentejac merged 3 commits into
developfrom
feature/set_custom_path_for_cache_dir
May 22, 2026
Merged

[graph] Add possibility to set a specific cacheDir in the mg scene#3077
cbentejac merged 3 commits into
developfrom
feature/set_custom_path_for_cache_dir

Conversation

@Alxiice
Copy link
Copy Markdown
Contributor

@Alxiice Alxiice commented Apr 14, 2026

Description

Add possibility to set a specific cache folder in the mg scene

  • In meshroom_batch a new option enables saving the scene with a specific cache folder.
  • a _explicitCacheDir parameter in the Graph tracks the explicit path we set (can be absolute or relative)
  • functions were added to set the default cache path or a custom one

About the Meshroom file :

  • graphIO : a CacheDir key was added to the serialized format. Serialization is designed to save the cacheDir inside the .mg file
  • graph : the deserialization is designed to load the explicit cache folder if we get one, and if we don't to select the default path (./MeshroomCache)
  • the serialized cacheDir can be a list, and in this case when deserialized we will iterate over elements and take the first one whose folder exists.

We can see the custom cache directory on the status bar :
image

Tests

Here is a command that can be used to set a new cache directory in a meshroom file

ROOT="..."
MG_FILE_IN="$ROOT/scene.mg"
MG_FILE_OUT="$MG_FILE_IN"
CACHE_DIR="$ROOT/MeshroomCache-v001"
meshroom_batch -p $MG_FILE_IN -s $MG_FILE_OUT --compute no --overrideCacheDir $CACHE_DIR

The following steps can test this feature :

  1. Create a new meshroom scene
  2. Compute the graph
  3. Close it
  4. Follow above script to set a new custom cache
  5. Open the scene
  6. You should see that the nodes are considered not computed (because we changed the cache to an empty folder). The new cache folder is set and can be seen on the status bar (at the bottom)
  7. Empty the previous cache folder (MeshroomCache)
  8. Launch the process on the current (new) scene
  9. It doesn't affect the original cache folder but the new cache is filled with the current scene nodes computation data

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 77.90698% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.93%. Comparing base (9a19925) to head (2a75c68).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
meshroom/core/graph.py 70.31% 19 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3077      +/-   ##
===========================================
- Coverage    83.98%   83.93%   -0.06%     
===========================================
  Files           83       83              
  Lines        10829    10910      +81     
===========================================
+ Hits          9095     9157      +62     
- Misses        1734     1753      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Alxiice Alxiice force-pushed the feature/set_custom_path_for_cache_dir branch 2 times, most recently from b1c1131 to 036dcba Compare April 17, 2026 13:29
ghost

This comment was marked as spam.

@sonarqubecloud
Copy link
Copy Markdown

@Alxiice Alxiice force-pushed the feature/set_custom_path_for_cache_dir branch from 036dcba to e1e8730 Compare May 4, 2026 15:27
@cbentejac cbentejac added this to the Meshroom 2026.1.0 milestone May 4, 2026
Copy link
Copy Markdown
Contributor

@cbentejac cbentejac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to add some tests on the serialization/deserialization of graphs with a specific cache directory to ensure we're covering all cases.

The test that's currently part of the PR only checks that the setExplicitCacheDir works as expected.

Otherwise, it all looks good to me!

@Alxiice Alxiice force-pushed the feature/set_custom_path_for_cache_dir branch from e1e8730 to 63bb2e7 Compare May 6, 2026 10:16
@Alxiice Alxiice requested a review from cbentejac May 6, 2026 14:44
@Alxiice Alxiice force-pushed the feature/set_custom_path_for_cache_dir branch 2 times, most recently from 3bc7b49 to 37ba04a Compare May 12, 2026 13:24
@Alxiice
Copy link
Copy Markdown
Contributor Author

Alxiice commented May 12, 2026

I added another system following @fcastan recommendations :
We can have a list as the explicit cacheDir
image
We browse the list fist-to-last and we check for existence :
image
If none of the elements in the list is found then it fallsback to the default location (./MeshroomCache)

@Alxiice Alxiice force-pushed the feature/set_custom_path_for_cache_dir branch from b091df8 to 22e7b4e Compare May 13, 2026 12:44
Comment thread meshroom/core/graph.py Fixed
Comment thread meshroom/core/graph.py Fixed
@Alxiice Alxiice force-pushed the feature/set_custom_path_for_cache_dir branch 4 times, most recently from e7b97a5 to 2a75c68 Compare May 20, 2026 09:13
@Alxiice Alxiice force-pushed the feature/set_custom_path_for_cache_dir branch from 2a75c68 to f78e7e0 Compare May 20, 2026 15:19
@cbentejac cbentejac dismissed their stale review May 22, 2026 09:51

Outdated change request.

@cbentejac cbentejac merged commit ecc6fdf into develop May 22, 2026
7 checks passed
@cbentejac cbentejac deleted the feature/set_custom_path_for_cache_dir branch May 22, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants