Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make grc use correct config paths #7350

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marcusmueller
Copy link
Member

@marcusmueller marcusmueller commented May 17, 2024

  • runtime/paths: add persistent() for persistent application data
  • GRC: GR config & persistent state location instead of ~/.gnuradio || ~/.grc_gnuradio

Description

As discussed in GRC Development,
it would be the right thing if GRC configuration ends up in the same tree as
GNU Radio itself stores configuration. (And we're now doing XDG_CONFIG_HOME,
unless that doesn't exist, but the legacy .gnuradio does.)

Same for generated hier blocks: they should live in a standard persistent state
directory. And for caches from the example browser and block lib, use the
appropriate cache dir.

Luckily, GNU Radio offers these paths by now; gr.paths is your friend. Just
need to use them.

We're also including fallbacks, should importing that fail for whatever reason.

Related Issues

Closes #7337

Which blocks/areas does this affect?

GRC Qt, GTK, converter

We add (no API breakage) a persistent getter to sys_paths and export it to python.

Checklist

@@ -53,6 +53,7 @@ class Paths(object):
TOP_BLOCK_FILE_MODE = HIER_BLOCK_FILE_MODE | stat.S_IXUSR | stat.S_IXGRP

# Setup paths
# FIXME: this should use ..main.get_config_directory() and get_state_directory(), probably.
Copy link
Member Author

Choose a reason for hiding this comment

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

@haakov I wasn't sure what to do with the commented-out code. Do we get to keep it or should we clean it up?

Copy link
Contributor

Choose a reason for hiding this comment

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

I kind of want to get rid of this file. We have Config.py, we have Constants.py, and we have Platform.py in the same directory, and I'm not quite sure what goes where. Maybe we can move the contents of this file to the others?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, then let's do that, it's OK enough an effort to be done quickly; but let's keep that out of this PR, then. I guess that especially means that the commented out code on Lines 57ff will just be removed.

@willcode willcode added the Backport-3.10 Should be backported to 3.10 label May 17, 2024
@marcusmueller marcusmueller force-pushed the make_grc_use_correct_config_paths branch from 5a73405 to 836257d Compare May 17, 2024 14:12
@@ -133,7 +133,12 @@ def build_library(self, path=None):
self.cpp_connection_templates.clear()
self._block_categories.clear()

with Cache(Constants.CACHE_FILE, version=self.config.version) as cache:
try:
Copy link
Member

Choose a reason for hiding this comment

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

How can this fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

my mental model was that GRC is something we perspectively want to move out of the GR tree and make less tightly version-coupled.

In the wake of that, depending on the very recent addition of gr.paths (or gr.paths.persistent) is still sensible (because we're still having GRC in-tree), but falling back gracefully in this place makes it easier to use "new" GRC with "old" GRC in the future.

@willcode
Copy link
Member

I guess that's a general comment ... why are we assuming that an import from our own package could fail?

@willcode
Copy link
Member

Not for this PR, but a wiki writeup of all the "if here", nope, "look there", hmm, "maybe over here", "copy to new place", etc., logic recently added to GRC would be good.

@willcode
Copy link
Member

Since caching is just for startup performance, is there really a need to make that part backward compatible? Even switching back and forth between two GRC versions will just cause two caches to be kept up to date.

@marcusmueller
Copy link
Member Author

Since caching is just for startup performance, is there really a need to make that part backward compatible? Even switching back and forth between two GRC versions will just cause two caches to be kept up to date.

You're right!

@marcusmueller marcusmueller force-pushed the make_grc_use_correct_config_paths branch from ad49349 to eb2cc2a Compare May 26, 2024 19:05
@marcusmueller
Copy link
Member Author

Since caching is just for startup performance, is there really a need to make that part backward compatible? Even switching back and forth between two GRC versions will just cause two caches to be kept up to date.

Thinking about this some more: you're right, no need to be backwards-compatible (which is great for backporting, I guess!), but we still shouldn't crash if we are faced with the old API only. So, I don't think there's anything to change here :)

Esp. to be used for GRC-generated python etc.

Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
@marcusmueller marcusmueller force-pushed the make_grc_use_correct_config_paths branch from eb2cc2a to 1f593b4 Compare May 26, 2024 19:11
@marcusmueller
Copy link
Member Author

squashed

@marcusmueller
Copy link
Member Author

@willcode ping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GRC ignores gr::prefs directories
3 participants