Skip to content

Save layer references relative to the graph - #126

Open
enriquevelmai wants to merge 1 commit into
nxt-dev:devfrom
enriquevelmai:feature/portable-references
Open

enriquevelmai wants to merge 1 commit into
nxt-dev:devfrom
enriquevelmai:feature/portable-references

Conversation

@enriquevelmai

Copy link
Copy Markdown

When a layer is saved, absolute reference paths are rewritten relative to the directory the layer is saved to (./sub/graph.nxt, ../shared/graph.nxt). References are already resolved relative to the parent layer on load, so this only makes the saved form portable: a graph folder can be moved, checked in or shared without every reference breaking.

  • Already relative references and references starting with an environment variable ($GRAPHS/...) are left untouched.
  • Paths that cannot be made relative (another Windows drive) are kept absolute.
  • comp_overrides keys are remapped together with the reference so mute/solo overrides stay attached.
  • Only the save data is rewritten; the live SpecLayer state keeps whatever path it was given.

Tests added in test_layer.py.

Absolute reference paths are rewritten relative to the directory the
layer is saved to, so a graph folder can be moved or shared without
breaking its references. References that are already relative or start
with an environment variable are left untouched, as are paths that
cannot be made relative (another Windows drive). comp_overrides keys are
remapped with the reference. Only the save data changes, never the live
layer state.
@michaelharmonart

michaelharmonart commented Sep 5, 2026 •

Copy link
Copy Markdown

I feel like this is a step up from default behavior. It still doesn't feel quite right to me.

If im working in a "stock" NXT install I would hope layer references are made relative but only if they are relative like .sub/graph.nxt but probably not ../../../../Documents/project/graph.nxt

We also make good use of the NXT_ROOT_PATHS in nxt/plugins/file_fallbacks.py in our pipeline to allow user working directories that can have sparse checkouts and a branch based development merge back to production after a feature or fix is complete.

I know this is technically plugin functionality, but if somehow there was a way for the relative pathing to make use of that feature, it would be much more useful for us.

Maybe plugins should be able to provide absolute -> relative path resolve somehow? Simplest/shortest final relative path wins?

@wyoder

wyoder commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

@enriquevelmai and @michaelharmonart we will take a look. Thank you for the PR. Should get back to you soon.

@wyoder
wyoder self-requested a review September 24, 2026 14:50
@wyoder

wyoder commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

We currently have a working version with reference editor. We plan to push out updates that should solve this and other PR issues. We will check this PR against our latest version and respond here soon

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