Commit graph

12222 commits

Author SHA1 Message Date
Šarūnas Nejus
b80b898ba8
test_bareasc: Add teardown which removes tmp files 2024-07-02 10:39:10 +01:00
Arav K.
2fc501f398 [beets.util.hidden] Disambiguate Win32 attribute logic
See: <https://github.com/beetbox/beets/pull/5341#discussion_r1658172880>
2024-06-28 08:11:10 +02:00
Arav K.
484400f701 [beets.util.hidden] Check for a 'st_flags' field
This check existed in the original implementation, but I had removed it
due to a misinterpretation of the 'os' documentation, thinking that the
field was guaranteed to exist.
2024-06-27 15:16:53 +02:00
Arav K.
3a09335e63 [beets.util.hidden] Note TODO for dropping 'bytes' inputs 2024-06-27 15:06:42 +02:00
Arav K.
b51f4cbd91 [util.hidden] use 'typing.Union' instead of '|' 2024-06-27 15:05:14 +02:00
Arav K.
f9b683225b Rework 'beets.util.hidden'
The implementation was unnecessarily convoluted.  I've rewritten it to
declare fewer functions, and it now uses 'pathlib'.
2024-06-27 14:59:21 +02:00
Arav K.
9a6245a593 Note the removal of beets.util.confit in the changelog 2024-06-26 02:11:57 +02:00
Arav K.
95dc07a404 Remove the 'confit' backport
The commit to deprecate 'confit' was made on June 1, 2019.  It's been 5
years!  It is now removed entirely.

See Also: e2d7780f97
2024-06-26 02:04:14 +02:00
Max Goltzsche
90f0ae2d93
fetchart: defer file removal config option eval
Defer the evaluation of the source file removal options (`import.delete` and `import.move`) to the point where the fetchart plugin is actually called instead of only evaluating those configuration options on plugin initialization.
This is to allow other plugins (such as the [ytimport](https://github.com/mgoltzsche/beets-ytimport/blob/v1.8.1/beetsplug/ytimport/__init__.py#L194) plugin) to invoke the import directly (within the same python process; implicitly invoking the fetchart plugin) with temporarily overwritten configuration options.

Relates to https://github.com/beetbox/beets/issues/5167#issuecomment-2106465172
2024-06-26 01:53:04 +02:00
Serene
240c5fca51
Refactor Candidate class in fetchart.py to improve resizing logic (#5152) 2024-06-25 14:30:49 +10:00
Serene
de0742b9d6
Merge branch 'master' into bug-fetchart-resize-logic-fix 2024-06-25 14:30:39 +10:00
Šarūnas Nejus
4e06b59b60
Filter albums by tracks fields and vice versa (#5327)
Fixes #4360

This PR enables querying albums by track fields and tracks by album
fields, and speeds up querying albums by `path` field.

It originally was part of #5240, however we found that the changes
related to the flexible attributes caused degradation in performance. So
this PR contains the first part of #5240 which joined `items` and
`albums` tables in queries.
2024-06-25 02:04:45 +01:00
Serene
f1c643d573
Use typing_extensions only when needed (#5331) 2024-06-24 14:33:11 +10:00
Arkadiy Illarionov
1c020b8264 Check Python version instead of catching ImportError 2024-06-22 19:55:52 +03:00
Arkadiy Illarionov
89f1bda4e0 Update poetry.lock 2024-06-22 16:18:56 +03:00
Arkadiy Illarionov
859072ee9e Use typing_extensions only when needed
Self was added in Python 3.11
TypeAlias was added in Python 3.10
2024-06-22 16:02:24 +03:00
Šarūnas Nejus
bcc2826000
Make sure we can filter common fields 2024-06-21 15:05:29 +01:00
Šarūnas Nejus
981a61bd56
Add support for filtering relations 2024-06-21 15:05:29 +01:00
Šarūnas Nejus
8e237d62c8
Make LazyClassProperty / cached_classproperty reusable 2024-06-21 08:49:10 +01:00
Serene
a273807569
Revert only fast queries (#5326)
Fixes: #5325 

As @arsaboo underlined, this change makes interaction with `beets`
unbearably slow for systems that have SQLite version below `3.38.0`.
This is what Ubuntu ships with by default.

I have also tested other commands, like `beet update`, and found that
even with up to date SQLite version, this command takes twice as long to
execute as before.

Thus, I think that the performance gain we see using some of the more
complex queries is not worth the performance loss for the most common
operations. Therefore, at least for now, I am reverting this change an
leaving this work on the `only-fast-filtering` branch to be revised.
2024-06-20 14:24:42 +10:00
Šarūnas Nejus
2800a323a2
Revert "Make queries fast, filter all flexible attributes (#5240)"
This reverts commit 143b9202f3, reversing
changes made to 8508a57d77.
2024-06-19 21:51:44 +01:00
Šarūnas Nejus
143b9202f3
Make queries fast, filter all flexible attributes (#5240)
Another and (hopefully) final attempt to improve querying speed.

Fixes #4360 
Fixes #3515
and possibly more issues to do with slow queries.

This PR supersedes #4746.

## What's been done
The `album` and `item` tables are joined, and corresponding data from
`item_attributes` and `album_attributes` is merged and made available
for filtering. This enables to achieve the following:

- [x] Faster album path queries, `beet list -a path::some/path` 
- [x] Faster flexible attributes queries, both albums and tracks, `beet
list play_count:10`
- [x] (New) Ability to filter albums with track-level (and vice-versa)
**db** field queries, `beet list -a title:something`
- [x] (New) Ability to filter tracks with album-level **flexible** field
queries, `beet list artpath:cover`
- [x] (New) Ability to filter albums with track-level **flexible** field
queries, `beet list -a art_source:something`

## Benchmarks

![image](https://github.com/beetbox/beets/assets/16212750/3136bc23-33ea-4f07-b93b-ff768b79fb0d)

You can see that now querying speed is more or less constant regardless
of the query, and the speed is mostly influenced by how many results
need to be printed out

![image](https://github.com/beetbox/beets/assets/16212750/bfb037fb-b8d3-46ca-9c30-f851d2af1887)

Compare this with what we had previously

![image](https://github.com/beetbox/beets/assets/16212750/38108879-a404-4cdf-90cc-5563e4a75f9f)

## Later
https://github.com/beetbox/beets/issues/5318
https://github.com/beetbox/beets/issues/5319
2024-06-17 09:10:47 +01:00
Šarūnas Nejus
2c4b42d167
Keep the same FieldQuery.field interface as before 2024-06-17 08:59:20 +01:00
Serene
8508a57d77
Bring back source files to codecov (#5316) 2024-06-17 09:56:59 +10:00
Šarūnas Nejus
2f80ff07e4
Add a changelog note and a mention in queries.rst 2024-06-16 23:44:07 +01:00
Šarūnas Nejus
e61c7d637d
fixup! Add ability to debug queries 2024-06-16 19:46:03 +01:00
Šarūnas Nejus
29da72b1d9
Show source files on codecov
While the commit merged yesterday fixed the coverage upload to
coveralls, it broke the source files preview on the platform.

This was due to the missing actions/checkout step in the coverage upload
job.
2024-06-16 18:24:48 +01:00
Šarūnas Nejus
11d584aa83
Define json functions for old SQLite versions 2024-06-16 17:56:44 +01:00
Šarūnas Nejus
1f93207823
Add any_writable_field_query to fix bpd search 2024-06-16 15:28:46 +01:00
Šarūnas Nejus
6792a75c7e
Ensure that any field query uses the table name
In order to include the table name for fields in this query, use the
`field_query` method.

Since `AnyFieldQuery` is just an `OrQuery` under the hood, remove it and
construct `OrQuery` explicitly instead.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
e0c50c5501
Remove slow lookups from beetsplug/aura
It seems like previously filtering by flexible attributes did not work
- I'd receive '{"data": []}' trying to GET `/aura/tracks?filter[play_count]=11`

Now this works, not only for tracks, but for `/aura/artists` and
`/aura/albums` too.

Additionally, this improves `/aura/tracks` response time significantly.
I tried loading the default of 500 tracks from my library:

On `master`, it took ~20s
After this commit, it takes under 1s.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
9207b17d13
Enable querying related flexible attributes
Unify query creation logic from
- queryparse.py:construct_query_part,
- Model.field_query,
- DefaultTemplateFunctions._tmpl_unique

to a single implementation under `LibModel.field_query` class method.
This method should be used for query resolution for model (flex)fields.

Allow filtering item attributes in album queries and vice versa by
merging `flex_attrs` from Album and Item together as `all_flex_attrs`.
This field is only used for filtering and is discarded after.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
484c00e223
Add ability to filter flexible attributes through the Query
For a flexible attribute query, replace the `col_name` property with
a function call that extracts that attribute from the `field_attrs`
field introduced in the earlier commit.

Additionally, for boolean, numeric and date queries CAST the value to
NUMERIC SQLite affinity to ensure that our queries like 'flex:1..5' and
'flex:true' continue working fine.

This removes the concept of 'slow query', since every query for any
field now has an SQL clause.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
969d847110
Aggregate flexible attributes
Use `json_group_object` SQLite function to aggregate flexible attributes
into `flex_attrs` field.

Register SQLite converter `json.loads` to automatically convert the JSON
string to a Python dictionary. Remove the code that had this task
previously.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
b0154d5cde
Fix querying fields present in both tables 2024-06-16 15:28:45 +01:00
Šarūnas Nejus
1862c7367b
Add ability to debug queries 2024-06-16 15:28:45 +01:00
Šarūnas Nejus
3347020c6c
Add support for filtering relations 2024-06-16 15:28:45 +01:00
Šarūnas Nejus
265e40b14e
Make LazyClassProperty / cached_classproperty reusable 2024-06-16 14:20:07 +01:00
Šarūnas Nejus
0e87389994
Replace py3_path and cpu_count implementations with builtins (#5227)
Replace py3_path by standard os.fsdecode and use native os.cpu_count.

These functions had been written before builtins achieving the same have
been made available (in Python 3.2 and 3.4). 

Now that they are available though, this PR updates the codebase to use
builtin implementations rather than the custom ones.
2024-06-16 11:50:27 +01:00
Šarūnas Nejus
6b63a3090d
Remove flake8 docstrings and its exclusion rules (#5234) 2024-06-16 02:55:49 +01:00
Šarūnas Nejus
076ec6f773
Do not run coverage by default (#5312)
Fixes #5242.

This PR moves coverage measurement from the default `pytest` invocation
to a separate action `test-with-coverage`.
2024-06-16 01:32:59 +01:00
Šarūnas Nejus
19470f3d76
Use native os.cpu_count
os.cpu_count has only been available since Python 3.4
2024-06-16 00:52:38 +01:00
Šarūnas Nejus
f388ff6ec1
Replace py3_path with builtin os.fsdecode
`os.fsdecode` has only been available since Python 3.2.
2024-06-16 00:52:37 +01:00
Šarūnas Nejus
0e1b5c20ed
Gitignore the .reports directory 2024-06-15 23:52:52 +01:00
Šarūnas Nejus
3e075f2a9a
Add 'test-with-coverage' command
And do not measure coverage by default.
2024-06-15 23:52:18 +01:00
Šarūnas Nejus
fa788e2e5a
Remove flake8-docstrings and its exclusion rules 2024-06-15 13:09:33 +01:00
Šarūnas Nejus
494c67603a
Fix running tests with/without coverage (#5309)
Apparently the `!` operator does not exist in GitHub Actions.

Also fix coverage upload.
2024-06-15 10:15:53 +01:00
Šarūnas Nejus
30d345dd7d
Try fixing coverage 2024-06-15 10:07:29 +01:00
Serene
bbb9aad6fa
Update release workflow with poetry (#5308) 2024-06-15 18:56:08 +10:00
Šarūnas Nejus
49e6012398
Try fixing testing workflow 2024-06-15 09:19:54 +01:00