KenKundert / borg-space

Accessory for Emborg used to report and track the size of your Borg repositories
GNU General Public License v3.0
4 stars 1 forks source link

v2 seems to require a config file #6

Closed adhawkins closed 1 year ago

adhawkins commented 1 year ago

Since upgrading to borg-space v2, it now seems to require a config file to be present:

xcp-alpine-emborg:~/.config/emborg# borg-space -r downloads
borg-space error: /root/.config/borg-space/settings.nt:
    /root/.config/borg-space/settings.nt: no such file or directory.

What is the minimum content of this file? If I create an empty one it complains about a missing 'repositories' entry. If I create one, with a single repository name in it, I get:

xcp-alpine-emborg:~/.config/emborg# borg-space -r downloads
Traceback (most recent call last):
  File "/usr/bin/borg-space", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/borg_space/main.py", line 329, in main
    repos = collect_repos(requests, cmdline['--record'])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg_space/main.py", line 69, in collect_repos
    repos = get_repos(request)
            ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg_space/config.py", line 216, in get_repos
    to_process.extend(gather(child))
                      ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg_space/config.py", line 192, in gather
    if name.isidentifier() and name in repositories:
       ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'isidentifier'

This is the contents of the settings file:

xcp-alpine-emborg:~/.config/emborg# cat ~/.config/borg-space/settings.nt
repositories:
    downloads:
adhawkins commented 1 year ago

Done a bit of digging, and it looks like the 'latest' files in the emborg cache directory don't include a 'size' value for the vast majority of them. I run:

emborg -c "$config" create --fast --stats
emborg -c "$config" prune --list --stats

for each emborg run. Recently, I manually ran:

emborg -v -c atom create

and this has added a 'size' entry. Does the --fast option prevent it from doing this? I can't remember why I'm using this, but I always have.

adhawkins commented 1 year ago

Yes, it look like it's the --fast option.

I was using that to prevent it doing a check and prune after each create. I notice I have these disabled in my global settings file anyway, so this probably isn't necessary.

The question about it requiring a config file still stands. Is a config file required for borg-space? If so, what is the minimum that is required in it?

KenKundert commented 1 year ago

Sorry about all this. When I went to confirm what you were seeing I found a number of other problems as well. This is an important lesson for me on the importance of an extensive set of regression tests. I am in the process of fixing all the issues and implementing the regression tests. The new version should be ready in a few days I would think. I really appreciate you digging in to this and reporting these problems.

I will look into seeing if I can make the size extraction work with the --fast option. If not, I will comment on it in the borg-space documentation.

In general, Emborg is written so that you should not need to run routinely with command line options. So if you find your self always needing to use a particular command line option, let me know and I will try to make it a configuration option.

KenKundert commented 1 year ago

Oh, and when I am finished with this new version, a config file will not be needed, but the minimum config file you tried would also work.

KenKundert commented 1 year ago

This issue should be fixed in the new version on github. Please give it a try and let me know how it works for you.

adhawkins commented 1 year ago

Can confirm that I can now run borg-space without a config file present

adhawkins commented 1 year ago

Are you planning an official release containing the recent fixes? I'll package it up for alpine once it's available.

KenKundert commented 1 year ago

I have done a formal release. The latest version is now up on PyPI. Thanks for testing my code and pointing out its issues. And thanks for updating the Alpine repositories. I really appreciate all that you do.

I noticed that you run borg-space for every Emborg create run. One to record the latest size and once to graph the size history. That is no longer necessary. You can include the --record option on a graphing borg-space command.

adhawkins commented 1 year ago

No problem regarding Alpine. I created the packages for purely selfish reasons, as I wanted a simple way to always be running the latest version.

Thanks for the pointer about running borg-space twice. Will update my configs.

KenKundert commented 1 year ago

I have updated github with the release candidate for version 2.2. If it is not too much trouble would you please run your tests. Once you give me the okay, I will release to pypi.

adhawkins commented 1 year ago

Just done that, passes the tests in their CI system. Will look out for an official release on github and update the Alpine package.