[3.2][Audio] Part 5 (Last) #3213

Closed
Drapersniper wants to merge 184 commits from part-5 into V3/develop
Drapersniper commented 2019-12-22 18:22:54 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

This is the last PR for the CPR, it depends on #3209, #3210, #3211 and #3212 and should be merged last

Description of the changes

Okay so this should in theory significantly improve audio performance across the border for folks that use the playlist function

@PredaaA using Mart on dev which has #2921 (which significantly reduces JSON size went from 50+MB prior to #2921 to 18.6MB prior to this PR)

With this PR his audio config went from 18.6MB to 287.12 KB... (and say we want to also migrate the EQUALIZER scope to an SQL table ... his config was reduced to 42.97 KB) which should significantly reduce write times and overall make audio commands feel speedier.

(Some more data With this PR @ Cat's config went from over 37MB to only 33kb, speeding up all commands that touches config)

### Type - [x] Bugfix - [x] Enhancement - [x] New feature ## This is the last PR for the CPR, it depends on #3209, #3210, #3211 and #3212 and should be merged last ### Description of the changes Okay so this should in theory significantly improve audio performance across the border for folks that use the playlist function @PredaaA using Mart on dev which has #2921 (which significantly reduces JSON size went from 50+MB prior to #2921 to 18.6MB prior to this PR) With this PR his audio config went from 18.6MB to 287.12 KB... (and say we want to also migrate the EQUALIZER scope to an SQL table ... his config was reduced to 42.97 KB) which should significantly reduce write times and overall make audio commands feel speedier. (Some more data With this PR @ Cat's config went from over 37MB to only 33kb, speeding up all commands that touches config)
palmtree5 (Migrated from github.com) reviewed 2019-12-22 18:22:54 +01:00
tekulvw (Migrated from github.com) reviewed 2019-12-22 18:22:54 +01:00
Twentysix26 (Migrated from github.com) reviewed 2019-12-22 18:22:54 +01:00
mikeshardmind (Migrated from github.com) reviewed 2019-12-28 08:35:58 +01:00
@ -185,3 +82,4 @@
) -> MutableMapping[str, str]:
if params is None:
params = {}
async with self.session.request("GET", url, params=params, headers=headers) as r:
mikeshardmind (Migrated from github.com) commented 2019-12-28 08:35:58 +01:00

MutableMapping should be used here instead of Mapping for the type (Same anywhere else you return a mapping which gets modified later so that dev toolings don't complain when opening the file)

`MutableMapping` should be used here instead of Mapping for the type (Same anywhere else you return a mapping which gets modified later so that dev toolings don't complain when opening the file)
mikeshardmind (Migrated from github.com) reviewed 2019-12-28 08:43:54 +01:00
mikeshardmind (Migrated from github.com) commented 2019-12-28 08:43:54 +01:00

(Note for later, not necessary to change in this PR, just noticed while reading through the full context)

The logic from here down including all branches attached to this if statement gets convoluted. There are 2 branches with identical implementations, separated by another branch. It's not valid to merge the branches directly either, and it won't be immediately obvious as to why. This should probably be looked at for a clarity improvement later on.

(Note for later, not necessary to change in this PR, just noticed while reading through the full context) The logic from here down including all branches attached to this if statement gets convoluted. There are 2 branches with identical implementations, separated by another branch. It's not valid to merge the branches directly either, and it won't be immediately obvious as to why. This should probably be looked at for a clarity improvement later on.
mikeshardmind commented 2019-12-28 08:55:31 +01:00 (Migrated from github.com)

I've not reviewed this or it's components in entirety or tested the full set of changes here.

I saw a few things which can have minor changes to be slightly better with tooling (mostly type hints)

I saw some logic and SQL that looks like it should work but should likely be handled as part of #3226 (The SQL even has a nice comment to some prior discussion regarding this in the code, +1)

I didn't see anything problematic code wise beyond this, but I have not tested the changes for being correct on the behavioral side. As I have been less involved with Audio's overall design and direction,

I'd prefer to leave judging if the behavioral parts are fine to other people more capable of determining that, especially since some of these changes are going to be more noticeable for people running larger public Red instances (such as cat, bb8, martine)

I've not reviewed this or it's components in entirety or tested the full set of changes here. I saw a few things which can have minor changes to be slightly better with tooling (mostly type hints) I saw some logic and SQL that looks like it should work but should likely be handled as part of #3226 (The SQL even has a nice comment to some prior discussion regarding this in the code, +1) I didn't see anything problematic code wise beyond this, but I have not tested the changes for being correct on the behavioral side. As I have been less involved with Audio's overall design and direction, I'd prefer to leave judging if the behavioral parts are fine to other people more capable of determining that, especially since some of these changes are going to be more noticeable for people running larger public Red instances (such as cat, bb8, martine)
aikaterna commented 2019-12-31 19:32:26 +01:00 (Migrated from github.com)

Using [p]search list searchterm with dj role on allows people to queue tracks when they shouldn't be allowed to.

Vote mode only, with DJ mode off:
The audioset vote setting should protect the prev command as well. People can use previous without being told no if vote is on.
Summon should also be protected in this mode, which it isn't at the moment.

Jukebox on, user had no currency

c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py:2770: RuntimeWarning: coroutine 'can_spend' was never awaited
  if not await self._currency_check(ctx, guild_data["jukebox_price"]):
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py:2781: RuntimeWarning: coroutine 'can_spend' was never awaited
  if not await self._currency_check(ctx, guild_data["jukebox_price"]):
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
[2019-12-31 10:17:53] [ERROR] red: ValueError
Traceback (most recent call last):
  File "c:\envs\3.1.8\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py", line 2770, in play
    if not await self._currency_check(ctx, guild_data["jukebox_price"]):
  File "c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py", line 7633, in _currency_check
    await bank.withdraw_credits(ctx.author, jukebox_price)
  File "c:\envs\3.1.8\lib\site-packages\redbot\core\bank.py", line 266, in withdraw_credits
    humanize_number(bal, override_locale="en_US"),
ValueError: Insufficient funds 10 > 0
c:\program files\python37\Lib\asyncio\events.py:88: RuntimeWarning: coroutine 'can_spend' was never awaited
  self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Using [p]search list searchterm with dj role on allows people to queue tracks when they shouldn't be allowed to. Vote mode only, with DJ mode off: The audioset vote setting should protect the prev command as well. People can use previous without being told no if vote is on. Summon should also be protected in this mode, which it isn't at the moment. Jukebox on, user had no currency ``` c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py:2770: RuntimeWarning: coroutine 'can_spend' was never awaited if not await self._currency_check(ctx, guild_data["jukebox_price"]): RuntimeWarning: Enable tracemalloc to get the object allocation traceback c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py:2781: RuntimeWarning: coroutine 'can_spend' was never awaited if not await self._currency_check(ctx, guild_data["jukebox_price"]): RuntimeWarning: Enable tracemalloc to get the object allocation traceback [2019-12-31 10:17:53] [ERROR] red: ValueError Traceback (most recent call last): File "c:\envs\3.1.8\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped ret = await coro(*args, **kwargs) File "c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py", line 2770, in play if not await self._currency_check(ctx, guild_data["jukebox_price"]): File "c:\envs\3.1.8\lib\site-packages\redbot\cogs\audio\audio.py", line 7633, in _currency_check await bank.withdraw_credits(ctx.author, jukebox_price) File "c:\envs\3.1.8\lib\site-packages\redbot\core\bank.py", line 266, in withdraw_credits humanize_number(bal, override_locale="en_US"), ValueError: Insufficient funds 10 > 0 c:\program files\python37\Lib\asyncio\events.py:88: RuntimeWarning: coroutine 'can_spend' was never awaited self._context.run(self._callback, *self._args) RuntimeWarning: Enable tracemalloc to get the object allocation traceback ```
Jackenmen commented 2020-01-01 01:45:22 +01:00 (Migrated from github.com)

Since Draper asked me, I'm mentioning this here.
[p]playlist download currently passes StringIO object to discord.File even though it only supports objects with binary data (i.e. BytesIO). While this haven't caused any troubles yet, this isn't the safeest thing to do.
I would advice using BytesIO objects instead and also explicitly using utf-8 encoding for saving and loading them to avoid any weird encoding issues.
Using StringIO made it save playlist files with ascii encoding, which utf-8 so happens to be compatible with.

Since Draper asked me, I'm mentioning this here. `[p]playlist download` currently passes `StringIO` object to `discord.File` even though it only supports objects with binary data (i.e. `BytesIO`). While this haven't caused any troubles yet, this isn't the safeest thing to do. I would advice using `BytesIO` objects instead and also explicitly using utf-8 encoding for saving and loading them to avoid any weird encoding issues. Using `StringIO` made it save playlist files with ascii encoding, which utf-8 so happens to be compatible with.
aikaterna commented 2020-01-03 17:23:13 +01:00 (Migrated from github.com)

I will be moving further testing and commenting to #3244 via Draper's direction on this.

I will be moving further testing and commenting to #3244 via Draper's direction on this.
aikaterna commented 2020-01-04 01:54:53 +01:00 (Migrated from github.com)

Closing as #3244 will be the merge for the cascading PR, and Draper asked me to.

Closing as #3244 will be the merge for the cascading PR, and Draper asked me to.

Pull request closed

Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!3213
No description provided.