Commit Graph

139 Commits

Author SHA1 Message Date
Michael Manganiello
ea9def4b85 misc: Replace deprecated uvicorn.workers with uvicorn-worker
According to the `uvicorn` docs [1], the `uvicorn.workers.UvicornWorker`
class is deprecated and replaced by the `uvicorn-worker` package [2].

[1] https://www.uvicorn.org/deployment/#gunicorn
[2] https://github.com/Kludex/uvicorn-worker
2025-07-05 12:59:49 -03:00
Michael Manganiello
2a0c328771 misc: Remove Python dependencies not being directly used
We can see in the `uv.lock` changes that we aren't actually removing
anything, but as these dependencies are not being directly accessed,
it's better to rely on direct dependencies only, in case they change
in the future and these indirect dependencies are no longer needed.
2025-07-05 00:11:17 -03:00
Georges-Antoine Assi
e8f8f1621c complete migration to uv 2025-07-04 09:54:04 -04:00
Georges-Antoine Assi
440ed0c954 use migrate-to-uv 2025-07-04 09:31:41 -04:00
Georges-Antoine Assi
15f0f1803e set python version in pyproject 2025-07-04 09:30:00 -04:00
Michael Manganiello
f96adeeaee misc: Upgrade to Python 3.13
Small changes to upgrade Python to version 3.13, and fixes based on a
`pyupgrade` run using the `--py313-plus` flag.
2025-07-03 23:37:00 -03:00
Michael Manganiello
195a1892d0 misc: Improve API docs and annotations for rom endpoints
* Add type annotations for FastAPI header, query, and path parameters.
* Add type annotations for request body content.
* Update docstrings to clarify endpoint functionality, and remove
  unnecessary details.
2025-06-29 11:56:01 -03:00
Georges-Antoine Assi
2e677decea Merge branch 'master' into romm-403 2025-06-09 17:20:17 -04:00
Michael Manganiello
c008cab4d7 misc: Move back to upstream streaming-form-data dependency
The breaking code in `streaming-form-data` has been fixed, and Poetry
also was patched based on @gantoine's proposed fix. This allows us
to use the official releases again instead of a fork.
2025-06-09 15:18:29 -03:00
Michael Manganiello
fe1a9ce2a7 fix: Use aiohttp for RetroAchievements API calls
This change replaces the `httpx` client with `aiohttp` for the
RetroAchievements API service.

The main reason for this change is that `httpx` has an unavoidable log
line with `INFO` level, which includes the request full URL, containing
the user's API key.

`httpx` has had an
[open discussion](https://github.com/encode/httpx/discussions/2765)
regarding this security issue for almost two years.

The change to `aiohttp` is painless, and would allow us to migrate more
of the codebase to it in the future, to avoid leaking sensitive
information in logs.
2025-06-09 09:59:56 -03:00
Georges-Antoine Assi
dcf622ed56 Merge branch 'master' into romm-403 2025-06-08 20:06:44 -04:00
Georges-Antoine Assi
3c2f32053b fix typo + bump redis + change heartbeat keys 2025-06-04 11:34:08 -04:00
Georges-Antoine Assi
ef0d84f589 Merge branch 'master' into romm-403 2025-05-29 09:58:35 -04:00
zurdi
491d351eb1 feat: implement custom logging middleware and configure logging settings 2025-05-23 00:15:33 +00:00
Georges-Antoine Assi
7d572ac0bf Merge branch 'master' into romm-403 2025-05-15 21:48:41 -04:00
zurdi
5ba5bb8543 feat: add show playables filter 2025-05-13 09:34:04 +00:00
Georges-Antoine Assi
f1f627f7c5 working pagination on roms endpoint 2025-03-14 21:10:30 -04:00
Georges-Antoine Assi
edd8286a44 Merge branch 'master' into romm-403 2025-01-31 12:15:31 -05:00
Michael Manganiello
f669f3f4fd misc: Upgrade rq to v2.1
Fixes #1526.
2025-01-22 10:18:57 -03:00
Georges-Antoine Assi
152c1365ce add launchbox metadata examples for testing 2025-01-21 00:09:06 -05:00
Georges-Antoine Assi
8cde4868e8 Merge branch 'master' into romm-403 2025-01-20 17:49:46 -05:00
Michael Manganiello
c018c75c35 misc: Add useful profiling tools to dev dependencies
`pyinstrument` for code profiling. `memray` for memory profiling.
2025-01-20 00:22:52 -03:00
Georges-Antoine Assi
0c95eff2e1 fetch and parse launchbox metadata.zip 2025-01-18 10:51:30 -05:00
Michael Manganiello
56631db636 fix: Poetry dependency installation during pytest job
With Poetry 2.0, we now need to explicitly tell it to install the `test`
extra.
2025-01-13 09:43:22 -03:00
Michael Manganiello
b683934e09 misc: Migrate optional dependencies to standard pyproject format 2025-01-12 13:55:50 -03:00
Michael Manganiello
245e225416 misc: Upgrade Poetry to v2.0
Release notes:
https://python-poetry.org/blog/announcing-poetry-2.0.0/
2025-01-12 12:41:55 -03:00
Michael Manganiello
573ec47159 misc: Move to py7zr v1.0.0rc2
Stop using `py7zr` fork and move to `1.0.0rc2` release, which includes
decompression streaming support.
2025-01-11 21:36:47 -03:00
Georges-Antoine Assi
6f120d9c4f hotfix poetry lock 2025-01-06 13:04:21 -05:00
Georges-Antoine Assi
ac1524fa4c Fork streaming-form-data and fix pyproject 2025-01-05 21:25:47 -05:00
Michael Manganiello
b9b7a8ccda fix: Make migrations compatible with PostgreSQL
This change only verifies that Alembic can upgrade and downgrade through
all the current migrations. It does not verify that the application
works correctly with PostgreSQL.
2024-12-30 08:36:05 -03:00
Michael Manganiello
7dc7eea34d feat: Initial Sentry support
This change initializes the Sentry SDK, which enables error tracking
when the `SENTRY_DSN` environment variable is set.

Drop-in alternatives to Sentry are also supported, like GlitchTip.
2024-12-27 17:03:45 -03:00
Michael Manganiello
a0bd575019 fix: MySQL migration and driver support
Trying to run MySQL as database (instead of MariaDB) was failing due to
incompatible migrations and lack of support for the MySQL driver.

These small changes fix the issue and recover the support for MySQL as
database driver.

Support for MySQL is on a best-effort basis, as the project's main
database is MariaDB.
2024-12-27 00:29:28 -03:00
Georges-Antoine Assi
2cd9041e85 Merge branch 'master' into openid-connect 2024-12-09 19:25:44 -05:00
Georges-Antoine Assi
b7dac4743a Merge branch 'master' into openid-connect 2024-12-07 22:19:24 -05:00
Michael Manganiello
743ecd83e7 misc: Fix some typing issues 2024-12-07 12:29:45 -03:00
zurdi
5bef403b83 upgrade fastapi to v0.115.6 2024-12-04 01:39:03 +00:00
dependabot[bot]
f61ae45ec4 build(deps): Bump python-multipart from 0.0.9 to 0.0.18
Bumps [python-multipart](https://github.com/Kludex/python-multipart) from 0.0.9 to 0.0.18.
- [Release notes](https://github.com/Kludex/python-multipart/releases)
- [Changelog](https://github.com/Kludex/python-multipart/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Kludex/python-multipart/compare/0.0.9...0.0.18)

---
updated-dependencies:
- dependency-name: python-multipart
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-02 22:37:26 +00:00
zurdi
a51dd03e1a Added full offline support and configurable logging level and API requests debug logs 2024-11-27 17:12:13 +00:00
Georges-Antoine Assi
3a91b7ba54 Merge branch 'master' into openid-connect 2024-11-26 19:52:18 -05:00
Michael Manganiello
477d9b1744 feat: Add streaming support for 7zip hashing
At the moment, 7zip files are generating memory issues and even OOM
errors on user installations. This is because the current stable release
of `py7zr` does not support decompression streaming, and RomM needs to
decompress the each 7zip file in the library into memory to be able to
calculate hashes.

This change introduces a `py7zr` fork I created to have a stable commit
SHA to refer to in case upstream gets any forced pushes. It includes the
contents of the pull request the `py7zr` creator is working on to
support decompression streaming [1].

The way decompression streaming is implemented in `py7zr` is different
than the other compression utilities. Instead of being able to provide a
`bytes` iterator, we need to provide a `Py7zIO` implementation that
will call a callback on each read and write operation.

[1] https://github.com/miurahr/py7zr/pull/620
2024-11-08 21:31:11 -03:00
Michael Manganiello
4bb5cb5149 misc: Initial addition of IGDB typehints
The short-term goal is to completely typehint the IGDB API responses. This
first change adds the base structures and enums RomM currently uses.

The `ExpandableField` type will allow us to model the expansion
mechanism the IGDB API provides, where a field can include either an ID,
or the full nested structure.
2024-10-27 00:02:01 -03:00
Michael Manganiello
b81fbc5820 fix: Improve handling of Redis URL
This change replaces the creation of Redis URL, from a simple string
interpolation, to using `yarl.URL`. The main benefit, besides not
forgetting to set all five different variables on every Redis client
initialization, is that user credentials are correctly URL-encoded, if
present.

Up until now, if a password had special characters, it could break the
generated URL.

This change also introduces support for a `REDIS_SSL` setting, which
allows the user to specify if the Redis connection should use SSL or not.
2024-10-11 21:41:19 -03:00
Michael Manganiello
149098fb31 fix: Improve memory usage during 7zip decompression
This change improves memory usage, by only keeping a single archive's
member file in memory at a time during 7zip decompression.

The `py7zr` library does not support streaming decompression yet, so
this change is the best we can do for now.

Potential fix for #1211, but it won't improve memory usage for
single-file 7zip archives.
2024-10-06 20:18:49 -03:00
Georges-Antoine Assi
00c8771e22 [ROMM0-1155] Patch zipfil + catch more 7zip errors 2024-09-01 21:58:22 -04:00
Michael Manganiello
0fad8ac282 feat: Use nginx mod_zip to generate multi-file zip downloads
This change installs and configures the `mod_zip` nginx module [1],
which allows nginx to stream ZIP files directly.

It includes a workaround needed to correctly calculate CRC-32 values for
included files, by including a new `server` section listening at port
8081, only used for the file requests to be upstream subrequests that
correctly trigger the CRC-32 calculation logic.

Also, to be able to provide a `m3u` file generated on the fly, we add a
`/decode` endpoint fully implemented in nginx using NJS, which receives
a `value` URL param, and decodes it using base64. The decoded value is
returned as the response.

That way, the contents of the `m3u` file is base64-encoded, and set as
part of the response, for `mod_zip` to include it in the ZIP file.

[1] https://github.com/evanmiller/mod_zip
2024-08-20 22:39:33 -03:00
Georges-Antoine Assi
a071c0a487 actual real upload streaming 2024-08-17 11:50:14 -04:00
Michael Manganiello
0fdbbe4625 misc: Upgrade Python to v3.12 and Alpine to v3.20
Included upgrades:
* Python: v3.12
* Alpine: v3.20 (which uses Python 3.12)
* nginx: v1.27.1
2024-08-15 20:14:32 -03:00
Georges-Antoine Assi
90e0e688b7 Merge branch 'master' into calc-file-hashes-roms 2024-08-09 11:36:50 -04:00
Georges-Antoine Assi
0fae870837 start work with fake openid add for testing 2024-08-04 00:41:34 -04:00
Michael Manganiello
16cb380cc0 misc: Use async interface for stream-zip
Replace use of synchronous `stream_zip` implementation, with
`async_stream_zip`. [1]

[1] https://stream-zip.docs.trade.gov.uk/async-interface/
2024-07-27 18:31:20 -03:00