Skip to content

[380][451][635] Cleanup of SteamCMD mod manifest + acf metadata on deletion - #623

Merged
twstagg merged 26 commits into
mainfrom
attempt-to-address-451
Oct 13, 2024
Merged

twstagg merged 26 commits into
mainfrom
attempt-to-address-451

Conversation

@twstagg

@twstagg twstagg commented Sep 29, 2024 •

Copy link
Copy Markdown
Collaborator

Attempts to fix #380, fix #451, fix #635

  • SteamCMD acf monitoring via Watchdog
  • Pops the metadata for the SteamCMD mod's publishedfileid when deleting via RimSort.
  • Removes the SteamCMD mod manifest file from the depotcache if found for the respective mod, after deleting.
  • Fix several minor bugs, utilize handle_remove_read_only in rmtree usages
  • Add support to ModInfo for descriptionbyversion tag
    • This is not documented on RimWorld wiki, but was tested and confirmed to be supported in-game mod manager.
  • Convert watchdog.py to use Sphinx reST format docstrings
  • Fix various MyPy errors
  • Pep604 instead of Typing.Optional everywhere
  • Replace Typing.List usages with list

@hk21702 hk21702 added bugs 🪲 bugs and errors, something is not working as intended feature/improvement 🆕 Use this label to mark new feature or improvement requests labels Sep 29, 2024
@hk21702 hk21702 linked an issue Sep 29, 2024 that may be closed by this pull request
@twstagg
twstagg marked this pull request as draft September 29, 2024 06:53
@hk21702 hk21702 changed the title Cleanup of SteamCMD mod manifest + acf metadata on deletion [451] Cleanup of SteamCMD mod manifest + acf metadata on deletion Sep 29, 2024

@hk21702 hk21702 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Posting summary of discussions from Discord.

Consider making steamcmd_purge_mod handle batches of mods instead of one at a time to reduce acf read and writes from n to 1 when doing deletions of multiple mods, maybe set self.workshop_acf_data to the post purge data at the end of steamcmd_purge_mod, on failure of reading acf in __refresh_acf_metadata, maybe set self.workshop_acf_data to the default value of an empty dict instead of leaving it as is, though I'm not entirely sure about this one on whats better tbh, and finally, consider doing is not None checks for your if statements involving .get() of parsed data for cases where the parsed data does exist, but the data just would happen to evaluate to False in Python like an empty string or 0

@twstagg

twstagg commented Oct 2, 2024

Copy link
Copy Markdown
Collaborator Author

Additionally implemented:

  • Watchdog acf file monitoring, refresh signal parses the files into MetadataManager on signal emission
    • PollingObserver is used for these due to probable bug on Windows with individual files being observed directly.

@twstagg

twstagg commented Oct 2, 2024

Copy link
Copy Markdown
Collaborator Author

Posting summary of discussions from Discord.

Consider making steamcmd_purge_mod handle batches of mods instead of one at a time to reduce acf read and writes from n to 1 when doing deletions of multiple mods, maybe set self.workshop_acf_data to the post purge data at the end of steamcmd_purge_mod, on failure of reading acf in __refresh_acf_metadata, maybe set self.workshop_acf_data to the default value of an empty dict instead of leaving it as is, though I'm not entirely sure about this one on whats better tbh, and finally, consider doing is not None checks for your if statements involving .get() of parsed data for cases where the parsed data does exist, but the data just would happen to evaluate to False in Python like an empty string or 0

Safer None-check has been implemented, and the overall process and flow is much more intuitive now.

@twstagg
twstagg marked this pull request as ready for review October 2, 2024 00:59
@twstagg
twstagg removed the request for review from LionelColaso October 5, 2024 18:53

@hk21702 hk21702 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are a few improvements to how the typing is done that can be implemented.

Additionally, some of the logic in the main window view should be moved into the controller, especially if it doesn't have to do with the manipulation of what the user directly sees. This can prob be done at a later date but just a heads up.

Comment thread app/utils/steam/steamcmd/wrapper.py Resolved
Comment thread app/utils/app_info.py Resolved
Comment thread app/utils/gui_info.py Resolved
Comment thread app/utils/metadata.py Resolved
Comment thread app/utils/system_info.py Resolved
Comment thread app/utils/watchdog.py Resolved
Comment thread app/views/dialogue.py Resolved
Comment thread app/views/main_window.py Resolved
Comment thread app/views/mods_panel.py Resolved
@hk21702

hk21702 commented Oct 11, 2024

Copy link
Copy Markdown
Collaborator

There will prob be significant merge conflicts when #576 is merged into main

@twstagg
twstagg force-pushed the attempt-to-address-451 branch from f15396a to aaa8824 Compare October 11, 2024 22:15
@twstagg
twstagg requested a review from hk21702 October 12, 2024 16:33
@twstagg twstagg changed the title [451] Cleanup of SteamCMD mod manifest + acf metadata on deletion [380][451] Cleanup of SteamCMD mod manifest + acf metadata on deletion Oct 13, 2024

@hk21702 hk21702 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems okay. May want to use the rmtree wrapper from utils.generic instead of directly from shutils but I will leave that up to you. Also may want to set depot cache clear setting to off by default as discussed.

@twstagg
twstagg force-pushed the attempt-to-address-451 branch from 42d2457 to bc78c9b Compare October 13, 2024 14:36
@twstagg twstagg changed the title [380][451] Cleanup of SteamCMD mod manifest + acf metadata on deletion [380][451][635] Cleanup of SteamCMD mod manifest + acf metadata on deletion Oct 13, 2024
@twstagg
twstagg merged commit 507a6d4 into main Oct 13, 2024
@twstagg
twstagg deleted the attempt-to-address-451 branch October 13, 2024 15:50
LionelColaso pushed a commit to LionelColaso/RimSort that referenced this pull request Oct 24, 2026
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from
3.16.0 to 3.17.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pytest-dev/pytest-mock/releases">pytest-mock's
releases</a>.</em></p>
<blockquote>
<h2>v3.17.0</h2>
<p><em>2026-10-17</em></p>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/641">#641</a>:
Failures of mock assertions such as <code>assert_called_with</code> are
again reported only once, instead of two or three times with the
original error from the <code>mock</code> module chained before
them.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/642">#642</a>:
Mock assertion failures no longer show misleading introspection when
they are not about the arguments of the last call:
<code>assert_called</code>, <code>assert_called_once</code>,
<code>assert_not_called</code>, <code>assert_any_call</code>, their
<code>await</code> counterparts, and
<code>assert_called_once_with</code>/<code>assert_awaited_once_with</code>
when the mock was not called (awaited) exactly once. The introspection
also no longer reports arguments passed by position versus by keyword as
different for autospecced mocks, and no longer shows empty
<code>Args:</code>/<code>Kwargs:</code> sections when assertion
rewriting is not available.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/643">#643</a>:
<code>assert_has_calls</code> and <code>assert_has_awaits</code>
failures no longer show pytest introspection, which compared the
expected and actual calls position by position and so reported
differences between unrelated calls. The mock's own message, listing the
expected and actual calls, is still shown.</li>
</ul>
<h2>v3.16.1</h2>
<p><em>2026-10-17</em></p>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/617">#617</a>:
Fixed <code>assert_has_calls</code> raising <code>ValueError</code>
instead of <code>AssertionError</code> (or showing misleading
introspection) when the expected calls are plain tuples rather than
<code>call(...)</code> objects, such as <code>(args, kwargs)</code>
entries of another mock's <code>call_args_list</code>,
<code>(args,)</code>, <code>(kwargs,)</code>, <code>(name, args)</code>
or <code>(name, kwargs)</code>.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/621">#621</a>:
Fixed <code>mocker.stop()</code> sometimes stopping the wrong mock, for
example with mocks from <code>mocker.create_autospec</code>.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/621">#621</a>:
<code>mocker.stop()</code> now undoes the most recent patch first when
the same object is used in several patches.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/623">#623</a>:
Fixed misleading introspection in <code>assert_has_awaits</code>
failures, and
<code>assert_has_calls</code>/<code>assert_has_awaits</code> raising
<code>IndexError</code> instead of <code>AssertionError</code> when
<code>calls</code> is passed by keyword.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/624">#624</a>:
Clear <code>spy_return_iter</code> after a spied synchronous or
asynchronous function raises, matching <code>spy_return</code>.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/627">#627</a>:
Document <code>async_stub</code> await assertions and the distinction
between call and await tracking.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/629">#629</a>:
Fixed <code>mocker.resetall()</code> skipping the mocks patched with
<code>mocker.patch.multiple()</code>, both the ones it creates and the
ones passed explicitly.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/630">#630</a>:
<code>mocker.resetall()</code> now also resets <code>spy_return</code>
and <code>spy_exception</code> of spies, like it already did for
<code>spy_return_list</code> and <code>spy_return_iter</code>, and no
longer overwrites attributes with these names on mocks that are not
spies.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest-mock/pull/633">#633</a>:
Fixed spies on <code>classmethod</code>, <code>staticmethod</code>,
builtins and classes returning a <code>MagicMock</code> instead of
calling the spied code after
<code>mocker.resetall(side_effect=True)</code>. Resetting a spy's
<code>side_effect</code> now goes back to calling the spied code, also
clearing any <code>side_effect</code> set on the spy.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst">pytest-mock's
changelog</a>.</em></p>
<blockquote>
<h2>3.17.0</h2>
<p><em>2026-10-17</em></p>
<ul>
<li><code>[RimSort#641](pytest-dev/pytest-mock#641)
&lt;https://github.com/pytest-dev/pytest-mock/pull/641&gt;</code>_:
Failures of mock assertions such as <code>assert_called_with</code> are
again reported only once, instead of two or three times with the
original error from the <code>mock</code> module chained before
them.</li>
<li><code>[RimSort#642](pytest-dev/pytest-mock#642)
&lt;https://github.com/pytest-dev/pytest-mock/pull/642&gt;</code>_: Mock
assertion failures no longer show misleading introspection when they are
not about the arguments of the last call: <code>assert_called</code>,
<code>assert_called_once</code>, <code>assert_not_called</code>,
<code>assert_any_call</code>, their <code>await</code> counterparts, and
<code>assert_called_once_with</code>/<code>assert_awaited_once_with</code>
when the mock was not called (awaited) exactly once. The introspection
also no longer reports arguments passed by position versus by keyword as
different for autospecced mocks, and no longer shows empty
<code>Args:</code>/<code>Kwargs:</code> sections when assertion
rewriting is not available.</li>
<li><code>[RimSort#643](pytest-dev/pytest-mock#643)
&lt;https://github.com/pytest-dev/pytest-mock/pull/643&gt;</code>_:
<code>assert_has_calls</code> and <code>assert_has_awaits</code>
failures no longer show pytest introspection, which compared the
expected and actual calls position by position and so reported
differences between unrelated calls. The mock's own message, listing the
expected and actual calls, is still shown.</li>
</ul>
<h2>3.16.1</h2>
<p><em>2026-10-17</em></p>
<ul>
<li><code>[RimSort#617](pytest-dev/pytest-mock#617)
&lt;https://github.com/pytest-dev/pytest-mock/pull/617&gt;</code>_:
Fixed <code>assert_has_calls</code> raising <code>ValueError</code>
instead of <code>AssertionError</code> (or showing misleading
introspection) when the expected calls are plain tuples rather than
<code>call(...)</code> objects, such as <code>(args, kwargs)</code>
entries of another mock's <code>call_args_list</code>,
<code>(args,)</code>, <code>(kwargs,)</code>, <code>(name, args)</code>
or <code>(name, kwargs)</code>.</li>
<li><code>[RimSort#621](pytest-dev/pytest-mock#621)
&lt;https://github.com/pytest-dev/pytest-mock/pull/621&gt;</code>_:
Fixed <code>mocker.stop()</code> sometimes stopping the wrong mock, for
example with mocks from <code>mocker.create_autospec</code>.</li>
<li><code>[RimSort#621](pytest-dev/pytest-mock#621)
&lt;https://github.com/pytest-dev/pytest-mock/pull/621&gt;</code>_:
<code>mocker.stop()</code> now undoes the most recent patch first when
the same object is used in several patches.</li>
<li><code>[RimSort#623](pytest-dev/pytest-mock#623)
&lt;https://github.com/pytest-dev/pytest-mock/pull/623&gt;</code>_:
Fixed misleading introspection in <code>assert_has_awaits</code>
failures, and
<code>assert_has_calls</code>/<code>assert_has_awaits</code> raising
<code>IndexError</code> instead of <code>AssertionError</code> when
<code>calls</code> is passed by keyword.</li>
<li><code>[RimSort#624](pytest-dev/pytest-mock#624)
&lt;https://github.com/pytest-dev/pytest-mock/pull/624&gt;</code>_:
Clear <code>spy_return_iter</code> after a spied synchronous or
asynchronous function raises, matching <code>spy_return</code>.</li>
<li><code>[RimSort#627](pytest-dev/pytest-mock#627)
&lt;https://github.com/pytest-dev/pytest-mock/pull/627&gt;</code>_:
Document <code>async_stub</code> await assertions and the distinction
between call and await tracking.</li>
<li><code>[RimSort#629](pytest-dev/pytest-mock#629)
&lt;https://github.com/pytest-dev/pytest-mock/pull/629&gt;</code>_:
Fixed <code>mocker.resetall()</code> skipping the mocks patched with
<code>mocker.patch.multiple()</code>, both the ones it creates and the
ones passed explicitly.</li>
<li><code>[RimSort#630](pytest-dev/pytest-mock#630)
&lt;https://github.com/pytest-dev/pytest-mock/pull/630&gt;</code>_:
<code>mocker.resetall()</code> now also resets <code>spy_return</code>
and <code>spy_exception</code> of spies, like it already did for
<code>spy_return_list</code> and <code>spy_return_iter</code>, and no
longer overwrites attributes with these names on mocks that are not
spies.</li>
<li><code>[RimSort#633](pytest-dev/pytest-mock#633)
&lt;https://github.com/pytest-dev/pytest-mock/pull/633&gt;</code>_:
Fixed spies on <code>classmethod</code>, <code>staticmethod</code>,
builtins and classes returning a <code>MagicMock</code> instead of
calling the spied code after
<code>mocker.resetall(side_effect=True)</code>. Resetting a spy's
<code>side_effect</code> now goes back to calling the spied code, also
clearing any <code>side_effect</code> set on the spy.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/5c2f207ca7098dde996f9bedd06e596e39b6246b"><code>5c2f207</code></a>
Release 3.17.0</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/96252715fad4a0dfec1997103cc231bc1f133616"><code>9625271</code></a>
Bump the minor version for releases that change existing behavior</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/34b87aeeef1d2a85be5ce4fadb0c6bc4a033c40a"><code>34b87ae</code></a>
Drop introspection from assert_has_calls and assert_has_awaits (<a
href="https://redirect.github.com/pytest-dev/pytest-mock/issues/643">#643</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/866520f2d339c7649af56ac227ca67ed36b1e92e"><code>866520f</code></a>
Only show introspection for failures about the call arguments (<a
href="https://redirect.github.com/pytest-dev/pytest-mock/issues/642">#642</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/5ab41c143c57842456caad0029082e919fa6a95d"><code>5ab41c1</code></a>
Do not chain the original mock error to wrapped assertion failures (<a
href="https://redirect.github.com/pytest-dev/pytest-mock/issues/641">#641</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/1916b14db224b893edf18251f26a38487eb0d6a6"><code>1916b14</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest-mock/issues/635">#635</a>
from nicoddemus/docs-contributing-resetall</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/212fcd903aeb685a3b39875be82fc84ff58ebc56"><code>212fcd9</code></a>
Document resetall, the changelog format and running tests with tox</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/9374b2c3e38e3bbc2e04328f7026ae3680f0476f"><code>9374b2c</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest-mock/issues/634">#634</a>
from pytest-dev/release-3.16.1</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/fab730daf4a4cfc260d8656b0467503131535a00"><code>fab730d</code></a>
Release 3.16.1</li>
<li><a
href="https://github.com/pytest-dev/pytest-mock/commit/d26d41bb01e99de5c0b59156c667d46985b03470"><code>d26d41b</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest-mock/issues/627">#627</a>
from xiehuanyi/docs/async-stub-awaits-20261012-r2</li>
<li>Additional commits viewable in <a
href="https://github.com/pytest-dev/pytest-mock/compare/v3.16.0...v3.17.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest-mock&package-manager=uv&previous-version=3.16.0&new-version=3.17.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugs 🪲 bugs and errors, something is not working as intended feature/improvement 🆕 Use this label to mark new feature or improvement requests

Projects

None yet

2 participants