Merge pull request 'feat(contracts): establish shared contracts package and toolchain alignment' (#11) from feat/contracts-workspace into main

This commit was merged in pull request #11.
This commit is contained in:
kiskaadee committed 2026-10-31 22:06:06 -05:00
commit 3d428dba48
18 files changed
+1077 -43

No files matched your search

+1 -4
View File
@@ -15,9 +15,6 @@ dist/
data/ data/
config/ config/
# Generated docs and proto stubs in services (if re-generated on build) # Local environment
docs/api_spec.md
.envrc .envrc
.direnv/ .direnv/
services/bff/src/bff/magnetflix/v1/
services/worker/src/worker/magnetflix/v1/
+4 -1
View File
@@ -1,7 +1,10 @@
.PHONY: generate test lint format check .PHONY: generate test lint format check
generate: generate:
uv run buf generate nix develop --command buf generate
test:
uv run pytest
lint: lint:
uv run ruff check . uv run ruff check .
+4 -12
View File
@@ -3,21 +3,13 @@ inputs:
- directory: proto - directory: proto
plugins: plugins:
- remote: buf.build/protocolbuffers/python - remote: buf.build/protocolbuffers/python
out: services/worker/src/worker out: services/contracts/src
- remote: buf.build/grpc/python - remote: buf.build/grpc/python
out: services/worker/src/worker out: services/contracts/src
- remote: buf.build/community/nipunn1313-mypy - remote: buf.build/community/nipunn1313-mypy
out: services/worker/src/worker out: services/contracts/src
- remote: buf.build/community/nipunn1313-mypy-grpc - remote: buf.build/community/nipunn1313-mypy-grpc
out: services/worker/src/worker out: services/contracts/src
- remote: buf.build/protocolbuffers/python
out: services/bff/src/bff
- remote: buf.build/grpc/python
out: services/bff/src/bff
- remote: buf.build/community/nipunn1313-mypy
out: services/bff/src/bff
- remote: buf.build/community/nipunn1313-mypy-grpc
out: services/bff/src/bff
- remote: buf.build/community/pseudomuto-doc - remote: buf.build/community/pseudomuto-doc
out: docs out: docs
opt: opt:
+243
View File
@@ -0,0 +1,243 @@
# Protocol Documentation
<a name="top"></a>
## Table of Contents
- [magnetflix/v1/pipeline.proto](#magnetflix_v1_pipeline-proto)
- [GetJobRequest](#magnetflix-v1-GetJobRequest)
- [GetJobResponse](#magnetflix-v1-GetJobResponse)
- [JobStatus](#magnetflix-v1-JobStatus)
- [ListJobsRequest](#magnetflix-v1-ListJobsRequest)
- [ListJobsResponse](#magnetflix-v1-ListJobsResponse)
- [StreamJobStatusRequest](#magnetflix-v1-StreamJobStatusRequest)
- [StreamJobStatusResponse](#magnetflix-v1-StreamJobStatusResponse)
- [SubmitDownloadRequest](#magnetflix-v1-SubmitDownloadRequest)
- [SubmitDownloadResponse](#magnetflix-v1-SubmitDownloadResponse)
- [JobState](#magnetflix-v1-JobState)
- [PipelineService](#magnetflix-v1-PipelineService)
- [Scalar Value Types](#scalar-value-types)
<a name="magnetflix_v1_pipeline-proto"></a>
<p align="right"><a href="#top">Top</a></p>
## magnetflix/v1/pipeline.proto
<a name="magnetflix-v1-GetJobRequest"></a>
### GetJobRequest
Request to fetch a specific job by ID.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| job_id | [string](#string) | | Unique job identifier. |
<a name="magnetflix-v1-GetJobResponse"></a>
### GetJobResponse
Response containing the status of the requested job.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| job | [JobStatus](#magnetflix-v1-JobStatus) | | The retrieved job details. |
<a name="magnetflix-v1-JobStatus"></a>
### JobStatus
Full status information for a download job.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| job_id | [string](#string) | | Unique job ID. |
| imdb_id | [string](#string) | | IMDb ID. |
| title | [string](#string) | | Resolved movie title from TMDB (if available). |
| year | [int32](#int32) | | Resolved release year from TMDB (if available). |
| requested_by | [string](#string) | | User who requested the download. |
| state | [JobState](#magnetflix-v1-JobState) | | Current state in the pipeline. |
| progress_pct | [float](#float) | | Download progress percentage (0.0 to 100.0). |
| download_rate_bytes | [int64](#int64) | | Download speed in bytes per second. |
| error_message | [string](#string) | | Detailed error message if the job failed. |
| created_at | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | Timestamp when the job was enqueued. |
| updated_at | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | Timestamp when the job status or progress was last updated. |
| completed_at | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | Timestamp when terminal processing finished (COMPLETED or FAILED). |
<a name="magnetflix-v1-ListJobsRequest"></a>
### ListJobsRequest
Request to list jobs with pagination and state filtering.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| page_size | [int32](#int32) | | Maximum number of jobs to return per page (default: 20, max: 100). |
| page_token | [string](#string) | | Page token received from a previous ListJobsResponse next_page_token. |
| state_filter | [JobState](#magnetflix-v1-JobState) | | Optional filter by job state. |
<a name="magnetflix-v1-ListJobsResponse"></a>
### ListJobsResponse
Paginated response containing a list of download jobs.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| jobs | [JobStatus](#magnetflix-v1-JobStatus) | repeated | List of matching jobs for the current page. |
| next_page_token | [string](#string) | | Token to retrieve the next page of results, or empty if no more results. |
<a name="magnetflix-v1-StreamJobStatusRequest"></a>
### StreamJobStatusRequest
Request to stream job updates.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| job_id | [string](#string) | | Optional job ID to filter updates for a single job; if empty, streams all active jobs. |
<a name="magnetflix-v1-StreamJobStatusResponse"></a>
### StreamJobStatusResponse
Real-time job status event stream frame.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| job | [JobStatus](#magnetflix-v1-JobStatus) | | Current job status update. |
<a name="magnetflix-v1-SubmitDownloadRequest"></a>
### SubmitDownloadRequest
Request to submit a new movie download.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| magnet_uri | [string](#string) | | Magnet URI of the torrent to fetch. |
| imdb_id | [string](#string) | | IMDb ID of the movie (e.g., &#34;tt1375666&#34;). |
| requested_by | [string](#string) | | Username of the user requesting the download (from Authelia Remote-User). |
<a name="magnetflix-v1-SubmitDownloadResponse"></a>
### SubmitDownloadResponse
Response acknowledging the job submission.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| job_id | [string](#string) | | Unique identifier for the created job. |
| message | [string](#string) | | Human-readable message. |
<a name="magnetflix-v1-JobState"></a>
### JobState
State enumeration of a download job lifecycle.
| Name | Number | Description |
| ---- | ------ | ----------- |
| JOB_STATE_UNSPECIFIED | 0 | |
| JOB_STATE_QUEUED | 1 | |
| JOB_STATE_DOWNLOADING | 2 | |
| JOB_STATE_SCANNING | 3 | |
| JOB_STATE_VERIFYING_METADATA | 4 | |
| JOB_STATE_ORGANIZING | 5 | |
| JOB_STATE_COMPLETED | 6 | |
| JOB_STATE_FAILED | 7 | |
<a name="magnetflix-v1-PipelineService"></a>
### PipelineService
PipelineService coordinates movie download jobs, safety scans, and library relocation.
| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| SubmitDownload | [SubmitDownloadRequest](#magnetflix-v1-SubmitDownloadRequest) | [SubmitDownloadResponse](#magnetflix-v1-SubmitDownloadResponse) | SubmitDownload enqueues a new movie download job. Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library. |
| GetJob | [GetJobRequest](#magnetflix-v1-GetJobRequest) | [GetJobResponse](#magnetflix-v1-GetJobResponse) | GetJob retrieves the current status and metadata of a specific job. |
| StreamJobStatus | [StreamJobStatusRequest](#magnetflix-v1-StreamJobStatusRequest) | [StreamJobStatusResponse](#magnetflix-v1-StreamJobStatusResponse) stream | StreamJobStatus streams real-time status updates. Semantics: Emits an immediate snapshot of matching active jobs upon connection, followed by subsequent state and progress change events. |
| ListJobs | [ListJobsRequest](#magnetflix-v1-ListJobsRequest) | [ListJobsResponse](#magnetflix-v1-ListJobsResponse) | ListJobs returns a paginated list of download jobs. |
## Scalar Value Types
| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- |
| <a name="double" /> double | | double | double | float | float64 | double | float | Float |
| <a name="float" /> float | | float | float | float | float32 | float | float | Float |
| <a name="int32" /> int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
| <a name="int64" /> int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum |
| <a name="uint32" /> uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) |
| <a name="uint64" /> uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) |
| <a name="sint32" /> sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
| <a name="sint64" /> sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum |
| <a name="fixed32" /> fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) |
| <a name="fixed64" /> fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum |
| <a name="sfixed32" /> sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
| <a name="sfixed64" /> sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum |
| <a name="bool" /> bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass |
| <a name="string" /> string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) |
| <a name="bytes" /> bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) |
+6 -5
View File
@@ -23,14 +23,15 @@ dev = [
[tool.pyright] [tool.pyright]
venvPath = "." venvPath = "."
venv = ".venv" venv = ".venv"
extraPaths = ["services/bff/src", "services/worker/src"] extraPaths = ["services/bff/src", "services/worker/src", "services/contracts/src"]
include = ["services"] include = ["services/bff", "services/worker", "tests"]
exclude = ["**/__pycache__", "services/**/magnetflix/"] exclude = ["**/__pycache__"]
reportIncompatibleVariableOverride = "none"
[tool.ruff] [tool.ruff]
line-length = 88 line-length = 88
target-version = "py312" target-version = "py312"
extend-exclude = ["services/**/magnetflix/"] extend-exclude = ["services/contracts/src/magnetflix/v1/"]
[tool.ruff.lint] [tool.ruff.lint]
select = ["E", "F", "I"] select = ["E", "F", "I"]
@@ -39,5 +40,5 @@ select = ["E", "F", "I"]
asyncio_mode = "auto" asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function" asyncio_default_fixture_loop_scope = "function"
testpaths = ["tests"] testpaths = ["tests"]
pythonpath = ["services/bff/src", "services/worker/src"] pythonpath = ["services/bff/src", "services/worker/src", "services/contracts/src"]
+4
View File
@@ -11,6 +11,7 @@ dependencies = [
"protobuf>=7.36.1", "protobuf>=7.36.1",
"pydantic>=2.10.0", "pydantic>=2.10.0",
"uvicorn[standard]>=0.32.0", "uvicorn[standard]>=0.32.0",
"magnetflix-contracts",
] ]
[build-system] [build-system]
@@ -21,3 +22,6 @@ build-backend = "uv_build"
module-name = "bff" module-name = "bff"
module-root = "src" module-root = "src"
[tool.uv.sources]
magnetflix-contracts = { workspace = true }
+3
View File
@@ -0,0 +1,3 @@
# MagNetFlix Contracts
Shared Protobuf and gRPC stubs generated from `proto/` definitions for the MagNetFlix workspace.
+18
View File
@@ -0,0 +1,18 @@
[project]
name = "magnetflix-contracts"
version = "0.1.0"
description = "Protobuf and gRPC schemas and stubs for MagNetFlix"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"grpcio>=1.83.1",
"protobuf>=7.36.2",
]
[build-system]
requires = ["uv_build>=0.12.5,<0.13.0"]
build-backend = "uv_build"
[tool.uv.build-backend]
module-name = "magnetflix"
module-root = "src"
@@ -0,0 +1,3 @@
"""Shared Protobuf and gRPC schemas and stubs for MagNetFlix."""
__version__ = "0.1.0"
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: magnetflix/v1/pipeline.proto
# Protobuf Python Version: 7.36.2
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
7,
36,
2,
'',
'magnetflix/v1/pipeline.proto'
)
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1cmagnetflix/v1/pipeline.proto\x12\rmagnetflix.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"r\n\x15SubmitDownloadRequest\x12\x1d\n\nmagnet_uri\x18\x01 \x01(\tR\tmagnetUri\x12\x17\n\x07imdb_id\x18\x02 \x01(\tR\x06imdbId\x12!\n\x0crequested_by\x18\x03 \x01(\tR\x0brequestedBy\"I\n\x16SubmitDownloadResponse\x12\x15\n\x06job_id\x18\x01 \x01(\tR\x05jobId\x12\x18\n\x07message\x18\x02 \x01(\tR\x07message\"&\n\rGetJobRequest\x12\x15\n\x06job_id\x18\x01 \x01(\tR\x05jobId\"<\n\x0eGetJobResponse\x12*\n\x03job\x18\x01 \x01(\x0b\x32\x18.magnetflix.v1.JobStatusR\x03job\"/\n\x16StreamJobStatusRequest\x12\x15\n\x06job_id\x18\x01 \x01(\tR\x05jobId\"E\n\x17StreamJobStatusResponse\x12*\n\x03job\x18\x01 \x01(\x0b\x32\x18.magnetflix.v1.JobStatusR\x03job\"\x89\x01\n\x0fListJobsRequest\x12\x1b\n\tpage_size\x18\x01 \x01(\x05R\x08pageSize\x12\x1d\n\npage_token\x18\x02 \x01(\tR\tpageToken\x12:\n\x0cstate_filter\x18\x03 \x01(\x0e\x32\x17.magnetflix.v1.JobStateR\x0bstateFilter\"\xe4\x03\n\tJobStatus\x12\x15\n\x06job_id\x18\x01 \x01(\tR\x05jobId\x12\x17\n\x07imdb_id\x18\x02 \x01(\tR\x06imdbId\x12\x14\n\x05title\x18\x03 \x01(\tR\x05title\x12\x12\n\x04year\x18\x04 \x01(\x05R\x04year\x12!\n\x0crequested_by\x18\x05 \x01(\tR\x0brequestedBy\x12-\n\x05state\x18\x06 \x01(\x0e\x32\x17.magnetflix.v1.JobStateR\x05state\x12!\n\x0cprogress_pct\x18\x07 \x01(\x02R\x0bprogressPct\x12.\n\x13\x64ownload_rate_bytes\x18\x08 \x01(\x03R\x11\x64ownloadRateBytes\x12#\n\rerror_message\x18\t \x01(\tR\x0c\x65rrorMessage\x12\x39\n\ncreated_at\x18\n \x01(\x0b\x32\x1a.google.protobuf.TimestampR\tcreatedAt\x12\x39\n\nupdated_at\x18\x0b \x01(\x0b\x32\x1a.google.protobuf.TimestampR\tupdatedAt\x12=\n\x0c\x63ompleted_at\x18\x0c \x01(\x0b\x32\x1a.google.protobuf.TimestampR\x0b\x63ompletedAt\"h\n\x10ListJobsResponse\x12,\n\x04jobs\x18\x01 \x03(\x0b\x32\x18.magnetflix.v1.JobStatusR\x04jobs\x12&\n\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken*\xd9\x01\n\x08JobState\x12\x19\n\x15JOB_STATE_UNSPECIFIED\x10\x00\x12\x14\n\x10JOB_STATE_QUEUED\x10\x01\x12\x19\n\x15JOB_STATE_DOWNLOADING\x10\x02\x12\x16\n\x12JOB_STATE_SCANNING\x10\x03\x12 \n\x1cJOB_STATE_VERIFYING_METADATA\x10\x04\x12\x18\n\x14JOB_STATE_ORGANIZING\x10\x05\x12\x17\n\x13JOB_STATE_COMPLETED\x10\x06\x12\x14\n\x10JOB_STATE_FAILED\x10\x07\x32\xe8\x02\n\x0fPipelineService\x12]\n\x0eSubmitDownload\x12$.magnetflix.v1.SubmitDownloadRequest\x1a%.magnetflix.v1.SubmitDownloadResponse\x12\x45\n\x06GetJob\x12\x1c.magnetflix.v1.GetJobRequest\x1a\x1d.magnetflix.v1.GetJobResponse\x12\x62\n\x0fStreamJobStatus\x12%.magnetflix.v1.StreamJobStatusRequest\x1a&.magnetflix.v1.StreamJobStatusResponse0\x01\x12K\n\x08ListJobs\x12\x1e.magnetflix.v1.ListJobsRequest\x1a\x1f.magnetflix.v1.ListJobsResponseb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'magnetflix.v1.pipeline_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_JOBSTATE']._serialized_start=1227
_globals['_JOBSTATE']._serialized_end=1444
_globals['_SUBMITDOWNLOADREQUEST']._serialized_start=80
_globals['_SUBMITDOWNLOADREQUEST']._serialized_end=194
_globals['_SUBMITDOWNLOADRESPONSE']._serialized_start=196
_globals['_SUBMITDOWNLOADRESPONSE']._serialized_end=269
_globals['_GETJOBREQUEST']._serialized_start=271
_globals['_GETJOBREQUEST']._serialized_end=309
_globals['_GETJOBRESPONSE']._serialized_start=311
_globals['_GETJOBRESPONSE']._serialized_end=371
_globals['_STREAMJOBSTATUSREQUEST']._serialized_start=373
_globals['_STREAMJOBSTATUSREQUEST']._serialized_end=420
_globals['_STREAMJOBSTATUSRESPONSE']._serialized_start=422
_globals['_STREAMJOBSTATUSRESPONSE']._serialized_end=491
_globals['_LISTJOBSREQUEST']._serialized_start=494
_globals['_LISTJOBSREQUEST']._serialized_end=631
_globals['_JOBSTATUS']._serialized_start=634
_globals['_JOBSTATUS']._serialized_end=1118
_globals['_LISTJOBSRESPONSE']._serialized_start=1120
_globals['_LISTJOBSRESPONSE']._serialized_end=1224
_globals['_PIPELINESERVICE']._serialized_start=1447
_globals['_PIPELINESERVICE']._serialized_end=1807
# @@protoc_insertion_point(module_scope)
@@ -0,0 +1,327 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""
from collections import abc as _abc
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
import builtins as _builtins
import sys
import typing as _typing
if sys.version_info >= (3, 11):
from typing import TypeAlias as _TypeAlias, Never as _Never
else:
from typing_extensions import TypeAlias as _TypeAlias, Never as _Never
DESCRIPTOR: _descriptor.FileDescriptor
class _JobState:
ValueType = _typing.NewType("ValueType", _builtins.int)
V: _TypeAlias = ValueType # noqa: Y015
class _JobStateEnumTypeWrapper(_enum_type_wrapper._EnumTypeWrapper[_JobState.ValueType], _builtins.type):
DESCRIPTOR: _descriptor.EnumDescriptor
JOB_STATE_UNSPECIFIED: _JobState.ValueType # 0
JOB_STATE_QUEUED: _JobState.ValueType # 1
JOB_STATE_DOWNLOADING: _JobState.ValueType # 2
JOB_STATE_SCANNING: _JobState.ValueType # 3
JOB_STATE_VERIFYING_METADATA: _JobState.ValueType # 4
JOB_STATE_ORGANIZING: _JobState.ValueType # 5
JOB_STATE_COMPLETED: _JobState.ValueType # 6
JOB_STATE_FAILED: _JobState.ValueType # 7
class JobState(_JobState, metaclass=_JobStateEnumTypeWrapper):
"""State enumeration of a download job lifecycle."""
JOB_STATE_UNSPECIFIED: JobState.ValueType # 0
JOB_STATE_QUEUED: JobState.ValueType # 1
JOB_STATE_DOWNLOADING: JobState.ValueType # 2
JOB_STATE_SCANNING: JobState.ValueType # 3
JOB_STATE_VERIFYING_METADATA: JobState.ValueType # 4
JOB_STATE_ORGANIZING: JobState.ValueType # 5
JOB_STATE_COMPLETED: JobState.ValueType # 6
JOB_STATE_FAILED: JobState.ValueType # 7
Global___JobState: _TypeAlias = JobState # noqa: Y015
@_typing.final
class SubmitDownloadRequest(_message.Message):
"""Request to submit a new movie download."""
DESCRIPTOR: _descriptor.Descriptor
MAGNET_URI_FIELD_NUMBER: _builtins.int
IMDB_ID_FIELD_NUMBER: _builtins.int
REQUESTED_BY_FIELD_NUMBER: _builtins.int
magnet_uri: _builtins.str
"""Magnet URI of the torrent to fetch."""
imdb_id: _builtins.str
"""IMDb ID of the movie (e.g., "tt1375666")."""
requested_by: _builtins.str
"""Username of the user requesting the download (from Authelia Remote-User)."""
def __init__(
self,
*,
magnet_uri: _builtins.str = ...,
imdb_id: _builtins.str = ...,
requested_by: _builtins.str = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _Never # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["imdb_id", b"imdb_id", "magnet_uri", b"magnet_uri", "requested_by", b"requested_by"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___SubmitDownloadRequest: _TypeAlias = SubmitDownloadRequest # noqa: Y015
@_typing.final
class SubmitDownloadResponse(_message.Message):
"""Response acknowledging the job submission."""
DESCRIPTOR: _descriptor.Descriptor
JOB_ID_FIELD_NUMBER: _builtins.int
MESSAGE_FIELD_NUMBER: _builtins.int
job_id: _builtins.str
"""Unique identifier for the created job."""
message: _builtins.str
"""Human-readable message."""
def __init__(
self,
*,
job_id: _builtins.str = ...,
message: _builtins.str = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _Never # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["job_id", b"job_id", "message", b"message"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___SubmitDownloadResponse: _TypeAlias = SubmitDownloadResponse # noqa: Y015
@_typing.final
class GetJobRequest(_message.Message):
"""Request to fetch a specific job by ID."""
DESCRIPTOR: _descriptor.Descriptor
JOB_ID_FIELD_NUMBER: _builtins.int
job_id: _builtins.str
"""Unique job identifier."""
def __init__(
self,
*,
job_id: _builtins.str = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _Never # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["job_id", b"job_id"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___GetJobRequest: _TypeAlias = GetJobRequest # noqa: Y015
@_typing.final
class GetJobResponse(_message.Message):
"""Response containing the status of the requested job."""
DESCRIPTOR: _descriptor.Descriptor
JOB_FIELD_NUMBER: _builtins.int
@_builtins.property
def job(self) -> Global___JobStatus:
"""The retrieved job details."""
def __init__(
self,
*,
job: Global___JobStatus | None = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _typing.Literal["job", b"job"] # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["job", b"job"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___GetJobResponse: _TypeAlias = GetJobResponse # noqa: Y015
@_typing.final
class StreamJobStatusRequest(_message.Message):
"""Request to stream job updates."""
DESCRIPTOR: _descriptor.Descriptor
JOB_ID_FIELD_NUMBER: _builtins.int
job_id: _builtins.str
"""Optional job ID to filter updates for a single job; if empty, streams all active jobs."""
def __init__(
self,
*,
job_id: _builtins.str = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _Never # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["job_id", b"job_id"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___StreamJobStatusRequest: _TypeAlias = StreamJobStatusRequest # noqa: Y015
@_typing.final
class StreamJobStatusResponse(_message.Message):
"""Real-time job status event stream frame."""
DESCRIPTOR: _descriptor.Descriptor
JOB_FIELD_NUMBER: _builtins.int
@_builtins.property
def job(self) -> Global___JobStatus:
"""Current job status update."""
def __init__(
self,
*,
job: Global___JobStatus | None = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _typing.Literal["job", b"job"] # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["job", b"job"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___StreamJobStatusResponse: _TypeAlias = StreamJobStatusResponse # noqa: Y015
@_typing.final
class ListJobsRequest(_message.Message):
"""Request to list jobs with pagination and state filtering."""
DESCRIPTOR: _descriptor.Descriptor
PAGE_SIZE_FIELD_NUMBER: _builtins.int
PAGE_TOKEN_FIELD_NUMBER: _builtins.int
STATE_FILTER_FIELD_NUMBER: _builtins.int
page_size: _builtins.int
"""Maximum number of jobs to return per page (default: 20, max: 100)."""
page_token: _builtins.str
"""Page token received from a previous ListJobsResponse next_page_token."""
state_filter: Global___JobState.ValueType
"""Optional filter by job state."""
def __init__(
self,
*,
page_size: _builtins.int = ...,
page_token: _builtins.str = ...,
state_filter: Global___JobState.ValueType = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _Never # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["page_size", b"page_size", "page_token", b"page_token", "state_filter", b"state_filter"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___ListJobsRequest: _TypeAlias = ListJobsRequest # noqa: Y015
@_typing.final
class JobStatus(_message.Message):
"""Full status information for a download job."""
DESCRIPTOR: _descriptor.Descriptor
JOB_ID_FIELD_NUMBER: _builtins.int
IMDB_ID_FIELD_NUMBER: _builtins.int
TITLE_FIELD_NUMBER: _builtins.int
YEAR_FIELD_NUMBER: _builtins.int
REQUESTED_BY_FIELD_NUMBER: _builtins.int
STATE_FIELD_NUMBER: _builtins.int
PROGRESS_PCT_FIELD_NUMBER: _builtins.int
DOWNLOAD_RATE_BYTES_FIELD_NUMBER: _builtins.int
ERROR_MESSAGE_FIELD_NUMBER: _builtins.int
CREATED_AT_FIELD_NUMBER: _builtins.int
UPDATED_AT_FIELD_NUMBER: _builtins.int
COMPLETED_AT_FIELD_NUMBER: _builtins.int
job_id: _builtins.str
"""Unique job ID."""
imdb_id: _builtins.str
"""IMDb ID."""
title: _builtins.str
"""Resolved movie title from TMDB (if available)."""
year: _builtins.int
"""Resolved release year from TMDB (if available)."""
requested_by: _builtins.str
"""User who requested the download."""
state: Global___JobState.ValueType
"""Current state in the pipeline."""
progress_pct: _builtins.float
"""Download progress percentage (0.0 to 100.0)."""
download_rate_bytes: _builtins.int
"""Download speed in bytes per second."""
error_message: _builtins.str
"""Detailed error message if the job failed."""
@_builtins.property
def created_at(self) -> _timestamp_pb2.Timestamp:
"""Timestamp when the job was enqueued."""
@_builtins.property
def updated_at(self) -> _timestamp_pb2.Timestamp:
"""Timestamp when the job status or progress was last updated."""
@_builtins.property
def completed_at(self) -> _timestamp_pb2.Timestamp:
"""Timestamp when terminal processing finished (COMPLETED or FAILED)."""
def __init__(
self,
*,
job_id: _builtins.str = ...,
imdb_id: _builtins.str = ...,
title: _builtins.str = ...,
year: _builtins.int = ...,
requested_by: _builtins.str = ...,
state: Global___JobState.ValueType = ...,
progress_pct: _builtins.float = ...,
download_rate_bytes: _builtins.int = ...,
error_message: _builtins.str = ...,
created_at: _timestamp_pb2.Timestamp | None = ...,
updated_at: _timestamp_pb2.Timestamp | None = ...,
completed_at: _timestamp_pb2.Timestamp | None = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _typing.Literal["completed_at", b"completed_at", "created_at", b"created_at", "updated_at", b"updated_at"] # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["completed_at", b"completed_at", "created_at", b"created_at", "download_rate_bytes", b"download_rate_bytes", "error_message", b"error_message", "imdb_id", b"imdb_id", "job_id", b"job_id", "progress_pct", b"progress_pct", "requested_by", b"requested_by", "state", b"state", "title", b"title", "updated_at", b"updated_at", "year", b"year"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___JobStatus: _TypeAlias = JobStatus # noqa: Y015
@_typing.final
class ListJobsResponse(_message.Message):
"""Paginated response containing a list of download jobs."""
DESCRIPTOR: _descriptor.Descriptor
JOBS_FIELD_NUMBER: _builtins.int
NEXT_PAGE_TOKEN_FIELD_NUMBER: _builtins.int
next_page_token: _builtins.str
"""Token to retrieve the next page of results, or empty if no more results."""
@_builtins.property
def jobs(self) -> _containers.RepeatedCompositeFieldContainer[Global___JobStatus]:
"""List of matching jobs for the current page."""
def __init__(
self,
*,
jobs: _abc.Iterable[Global___JobStatus] | None = ...,
next_page_token: _builtins.str = ...,
) -> None: ...
_HasFieldArgType: _TypeAlias = _Never # noqa: Y015
def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool: ...
_ClearFieldArgType: _TypeAlias = _typing.Literal["jobs", b"jobs", "next_page_token", b"next_page_token"] # noqa: Y015
def ClearField(self, field_name: _ClearFieldArgType) -> None: ...
def WhichOneof(self, oneof_group: _Never) -> None: ...
Global___ListJobsResponse: _TypeAlias = ListJobsResponse # noqa: Y015
@@ -0,0 +1,216 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
from magnetflix.v1 import pipeline_pb2 as magnetflix_dot_v1_dot_pipeline__pb2
class PipelineServiceStub:
"""PipelineService coordinates movie download jobs, safety scans, and library relocation.
"""
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.SubmitDownload = channel.unary_unary(
'/magnetflix.v1.PipelineService/SubmitDownload',
request_serializer=magnetflix_dot_v1_dot_pipeline__pb2.SubmitDownloadRequest.SerializeToString,
response_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.SubmitDownloadResponse.FromString,
_registered_method=True)
self.GetJob = channel.unary_unary(
'/magnetflix.v1.PipelineService/GetJob',
request_serializer=magnetflix_dot_v1_dot_pipeline__pb2.GetJobRequest.SerializeToString,
response_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.GetJobResponse.FromString,
_registered_method=True)
self.StreamJobStatus = channel.unary_stream(
'/magnetflix.v1.PipelineService/StreamJobStatus',
request_serializer=magnetflix_dot_v1_dot_pipeline__pb2.StreamJobStatusRequest.SerializeToString,
response_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.StreamJobStatusResponse.FromString,
_registered_method=True)
self.ListJobs = channel.unary_unary(
'/magnetflix.v1.PipelineService/ListJobs',
request_serializer=magnetflix_dot_v1_dot_pipeline__pb2.ListJobsRequest.SerializeToString,
response_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.ListJobsResponse.FromString,
_registered_method=True)
class PipelineServiceServicer:
"""PipelineService coordinates movie download jobs, safety scans, and library relocation.
"""
def SubmitDownload(self, request, context):
"""SubmitDownload enqueues a new movie download job.
Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def GetJob(self, request, context):
"""GetJob retrieves the current status and metadata of a specific job.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def StreamJobStatus(self, request, context):
"""StreamJobStatus streams real-time status updates.
Semantics: Emits an immediate snapshot of matching active jobs upon connection,
followed by subsequent state and progress change events.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def ListJobs(self, request, context):
"""ListJobs returns a paginated list of download jobs.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_PipelineServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'SubmitDownload': grpc.unary_unary_rpc_method_handler(
servicer.SubmitDownload,
request_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.SubmitDownloadRequest.FromString,
response_serializer=magnetflix_dot_v1_dot_pipeline__pb2.SubmitDownloadResponse.SerializeToString,
),
'GetJob': grpc.unary_unary_rpc_method_handler(
servicer.GetJob,
request_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.GetJobRequest.FromString,
response_serializer=magnetflix_dot_v1_dot_pipeline__pb2.GetJobResponse.SerializeToString,
),
'StreamJobStatus': grpc.unary_stream_rpc_method_handler(
servicer.StreamJobStatus,
request_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.StreamJobStatusRequest.FromString,
response_serializer=magnetflix_dot_v1_dot_pipeline__pb2.StreamJobStatusResponse.SerializeToString,
),
'ListJobs': grpc.unary_unary_rpc_method_handler(
servicer.ListJobs,
request_deserializer=magnetflix_dot_v1_dot_pipeline__pb2.ListJobsRequest.FromString,
response_serializer=magnetflix_dot_v1_dot_pipeline__pb2.ListJobsResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'magnetflix.v1.PipelineService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
server.add_registered_method_handlers('magnetflix.v1.PipelineService', rpc_method_handlers)
# This class is part of an EXPERIMENTAL API.
class PipelineService:
"""PipelineService coordinates movie download jobs, safety scans, and library relocation.
"""
@staticmethod
def SubmitDownload(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/magnetflix.v1.PipelineService/SubmitDownload',
magnetflix_dot_v1_dot_pipeline__pb2.SubmitDownloadRequest.SerializeToString,
magnetflix_dot_v1_dot_pipeline__pb2.SubmitDownloadResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)
@staticmethod
def GetJob(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/magnetflix.v1.PipelineService/GetJob',
magnetflix_dot_v1_dot_pipeline__pb2.GetJobRequest.SerializeToString,
magnetflix_dot_v1_dot_pipeline__pb2.GetJobResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)
@staticmethod
def StreamJobStatus(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_stream(
request,
target,
'/magnetflix.v1.PipelineService/StreamJobStatus',
magnetflix_dot_v1_dot_pipeline__pb2.StreamJobStatusRequest.SerializeToString,
magnetflix_dot_v1_dot_pipeline__pb2.StreamJobStatusResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)
@staticmethod
def ListJobs(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/magnetflix.v1.PipelineService/ListJobs',
magnetflix_dot_v1_dot_pipeline__pb2.ListJobsRequest.SerializeToString,
magnetflix_dot_v1_dot_pipeline__pb2.ListJobsResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)
@@ -0,0 +1,109 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""
from collections import abc as _abc
from grpc import aio as _aio
from magnetflix.v1 import pipeline_pb2 as _pipeline_pb2
import abc as _abc_1
import grpc as _grpc
import sys
import typing as _typing
if sys.version_info >= (3, 11):
from typing import Self as _Self
else:
from typing_extensions import Self as _Self
_T = _typing.TypeVar("_T")
class _MaybeAsyncIterator(_abc.AsyncIterator[_T], _abc.Iterator[_T], metaclass=_abc_1.ABCMeta): ...
class _ServicerContext(_grpc.ServicerContext, _aio.ServicerContext): # type: ignore[misc, type-arg]
...
GRPC_GENERATED_VERSION: str
GRPC_VERSION: str
class PipelineServiceStub:
"""PipelineService coordinates movie download jobs, safety scans, and library relocation."""
@_typing.overload
def __new__(cls, channel: _grpc.Channel) -> _Self: ...
@_typing.overload
def __new__(cls, channel: _aio.Channel) -> PipelineServiceAsyncStub: ...
SubmitDownload: _grpc.UnaryUnaryMultiCallable[_pipeline_pb2.SubmitDownloadRequest, _pipeline_pb2.SubmitDownloadResponse]
"""SubmitDownload enqueues a new movie download job.
Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library.
"""
GetJob: _grpc.UnaryUnaryMultiCallable[_pipeline_pb2.GetJobRequest, _pipeline_pb2.GetJobResponse]
"""GetJob retrieves the current status and metadata of a specific job."""
StreamJobStatus: _grpc.UnaryStreamMultiCallable[_pipeline_pb2.StreamJobStatusRequest, _pipeline_pb2.StreamJobStatusResponse]
"""StreamJobStatus streams real-time status updates.
Semantics: Emits an immediate snapshot of matching active jobs upon connection,
followed by subsequent state and progress change events.
"""
ListJobs: _grpc.UnaryUnaryMultiCallable[_pipeline_pb2.ListJobsRequest, _pipeline_pb2.ListJobsResponse]
"""ListJobs returns a paginated list of download jobs."""
@_typing.type_check_only
class PipelineServiceAsyncStub(PipelineServiceStub):
"""PipelineService coordinates movie download jobs, safety scans, and library relocation."""
def __init__(self, channel: _aio.Channel) -> None: ...
SubmitDownload: _aio.UnaryUnaryMultiCallable[_pipeline_pb2.SubmitDownloadRequest, _pipeline_pb2.SubmitDownloadResponse] # type: ignore[assignment]
"""SubmitDownload enqueues a new movie download job.
Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library.
"""
GetJob: _aio.UnaryUnaryMultiCallable[_pipeline_pb2.GetJobRequest, _pipeline_pb2.GetJobResponse] # type: ignore[assignment]
"""GetJob retrieves the current status and metadata of a specific job."""
StreamJobStatus: _aio.UnaryStreamMultiCallable[_pipeline_pb2.StreamJobStatusRequest, _pipeline_pb2.StreamJobStatusResponse] # type: ignore[assignment]
"""StreamJobStatus streams real-time status updates.
Semantics: Emits an immediate snapshot of matching active jobs upon connection,
followed by subsequent state and progress change events.
"""
ListJobs: _aio.UnaryUnaryMultiCallable[_pipeline_pb2.ListJobsRequest, _pipeline_pb2.ListJobsResponse] # type: ignore[assignment]
"""ListJobs returns a paginated list of download jobs."""
class PipelineServiceServicer(metaclass=_abc_1.ABCMeta):
"""PipelineService coordinates movie download jobs, safety scans, and library relocation."""
@_abc_1.abstractmethod
def SubmitDownload(
self,
request: _pipeline_pb2.SubmitDownloadRequest,
context: _ServicerContext,
) -> _typing.Union[_pipeline_pb2.SubmitDownloadResponse, _abc.Awaitable[_pipeline_pb2.SubmitDownloadResponse]]:
"""SubmitDownload enqueues a new movie download job.
Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library.
"""
@_abc_1.abstractmethod
def GetJob(
self,
request: _pipeline_pb2.GetJobRequest,
context: _ServicerContext,
) -> _typing.Union[_pipeline_pb2.GetJobResponse, _abc.Awaitable[_pipeline_pb2.GetJobResponse]]:
"""GetJob retrieves the current status and metadata of a specific job."""
@_abc_1.abstractmethod
def StreamJobStatus(
self,
request: _pipeline_pb2.StreamJobStatusRequest,
context: _ServicerContext,
) -> _typing.Union[_abc.Iterator[_pipeline_pb2.StreamJobStatusResponse], _abc.AsyncIterator[_pipeline_pb2.StreamJobStatusResponse]]:
"""StreamJobStatus streams real-time status updates.
Semantics: Emits an immediate snapshot of matching active jobs upon connection,
followed by subsequent state and progress change events.
"""
@_abc_1.abstractmethod
def ListJobs(
self,
request: _pipeline_pb2.ListJobsRequest,
context: _ServicerContext,
) -> _typing.Union[_pipeline_pb2.ListJobsResponse, _abc.Awaitable[_pipeline_pb2.ListJobsResponse]]:
"""ListJobs returns a paginated list of download jobs."""
def add_PipelineServiceServicer_to_server(servicer: PipelineServiceServicer, server: _typing.Union[_grpc.Server, _aio.Server]) -> None: ...
+4
View File
@@ -13,6 +13,7 @@ dependencies = [
"pydantic>=2.10.0", "pydantic>=2.10.0",
"sqlalchemy>=2.0.36", "sqlalchemy>=2.0.36",
"transmission-rpc>=7.0.11", "transmission-rpc>=7.0.11",
"magnetflix-contracts",
] ]
[build-system] [build-system]
@@ -23,3 +24,6 @@ build-backend = "uv_build"
module-name = "worker" module-name = "worker"
module-root = "src" module-root = "src"
[tool.uv.sources]
magnetflix-contracts = { workspace = true }
+3 -8
View File
@@ -8,11 +8,10 @@ from enum import Enum
from typing import Any from typing import Any
from google.protobuf.timestamp_pb2 import Timestamp from google.protobuf.timestamp_pb2 import Timestamp
from magnetflix.v1 import pipeline_pb2
from sqlalchemy import BigInteger, DateTime, Float, Integer, String, Text from sqlalchemy import BigInteger, DateTime, Float, Integer, String, Text
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from worker.magnetflix.v1 import pipeline_pb2
class Base(DeclarativeBase): class Base(DeclarativeBase):
"""Base declarative class for SQLAlchemy ORM models.""" """Base declarative class for SQLAlchemy ORM models."""
@@ -249,12 +248,8 @@ class DownloadJob(Base):
"progress_pct": self.progress_pct, "progress_pct": self.progress_pct,
"download_rate_bytes": self.download_rate_bytes, "download_rate_bytes": self.download_rate_bytes,
"error_message": self.error_message, "error_message": self.error_message,
"created_at": ( "created_at": (self.created_at.isoformat() if self.created_at else None),
self.created_at.isoformat() if self.created_at else None "updated_at": (self.updated_at.isoformat() if self.updated_at else None),
),
"updated_at": (
self.updated_at.isoformat() if self.updated_at else None
),
"completed_at": ( "completed_at": (
self.completed_at.isoformat() if self.completed_at else None self.completed_at.isoformat() if self.completed_at else None
), ),
+44
View File
@@ -0,0 +1,44 @@
"""Unit and contract seam tests for generated Protobuf and gRPC stubs."""
from __future__ import annotations
def test_protobuf_and_grpc_stubs_importable():
"""Verify that both pipeline_pb2 and pipeline_pb2_grpc import cleanly."""
from magnetflix.v1 import pipeline_pb2, pipeline_pb2_grpc
assert pipeline_pb2.JOB_STATE_QUEUED == 1
assert pipeline_pb2.JOB_STATE_DOWNLOADING == 2
assert hasattr(pipeline_pb2_grpc, "PipelineServiceServicer")
assert hasattr(pipeline_pb2_grpc, "PipelineServiceStub")
def test_proto_job_status_creation():
"""Verify that JobStatus protobuf message instantiates and serializes."""
from google.protobuf.timestamp_pb2 import Timestamp
from magnetflix.v1 import pipeline_pb2
ts = Timestamp()
ts.GetCurrentTime()
status = pipeline_pb2.JobStatus(
job_id="test-job-123",
imdb_id="tt1375666",
title="Inception",
year=2010,
requested_by="alice",
state=pipeline_pb2.JOB_STATE_QUEUED,
progress_pct=0.0,
download_rate_bytes=0,
error_message="",
created_at=ts,
)
assert status.job_id == "test-job-123"
assert status.title == "Inception"
serialized = status.SerializeToString()
assert len(serialized) > 0
deserialized = pipeline_pb2.JobStatus()
deserialized.ParseFromString(serialized)
assert deserialized.imdb_id == "tt1375666"
+2 -4
View File
@@ -6,6 +6,7 @@ import tempfile
from pathlib import Path from pathlib import Path
import pytest import pytest
from magnetflix.v1 import pipeline_pb2
from sqlalchemy import select from sqlalchemy import select
from worker.db import ( from worker.db import (
Base, Base,
@@ -14,7 +15,6 @@ from worker.db import (
create_engine, create_engine,
verify_wal_mode, verify_wal_mode,
) )
from worker.magnetflix.v1 import pipeline_pb2
@pytest.fixture @pytest.fixture
@@ -162,9 +162,7 @@ async def test_download_job_state_transitions(temp_db):
magnet_uri="magnet:?xt=urn:btih:godfather", magnet_uri="magnet:?xt=urn:btih:godfather",
requested_by="charlie", requested_by="charlie",
) )
job_failing.transition_to( job_failing.transition_to(JobStateEnum.FAILED, error_message="Tracker timed out")
JobStateEnum.FAILED, error_message="Tracker timed out"
)
assert job_failing.state == JobStateEnum.FAILED.value assert job_failing.state == JobStateEnum.FAILED.value
assert job_failing.error_message == "Tracker timed out" assert job_failing.error_message == "Tracker timed out"
assert job_failing.is_terminal is True assert job_failing.is_terminal is True
Generated
+29 -9
View File
@@ -5,6 +5,7 @@ requires-python = ">=3.12"
[manifest] [manifest]
members = [ members = [
"magnetflix-bff", "magnetflix-bff",
"magnetflix-contracts",
"magnetflix-worker", "magnetflix-worker",
"magnetflix-workspace", "magnetflix-workspace",
] ]
@@ -499,6 +500,7 @@ dependencies = [
{ name = "fastapi" }, { name = "fastapi" },
{ name = "grpcio" }, { name = "grpcio" },
{ name = "jinja2" }, { name = "jinja2" },
{ name = "magnetflix-contracts" },
{ name = "protobuf" }, { name = "protobuf" },
{ name = "pydantic" }, { name = "pydantic" },
{ name = "uvicorn", extra = ["standard"] }, { name = "uvicorn", extra = ["standard"] },
@@ -509,11 +511,27 @@ requires-dist = [
{ name = "fastapi", specifier = ">=0.115.0" }, { name = "fastapi", specifier = ">=0.115.0" },
{ name = "grpcio", specifier = ">=1.83.1" }, { name = "grpcio", specifier = ">=1.83.1" },
{ name = "jinja2", specifier = ">=3.1.4" }, { name = "jinja2", specifier = ">=3.1.4" },
{ name = "magnetflix-contracts", editable = "services/contracts" },
{ name = "protobuf", specifier = ">=7.36.1" }, { name = "protobuf", specifier = ">=7.36.1" },
{ name = "pydantic", specifier = ">=2.10.0" }, { name = "pydantic", specifier = ">=2.10.0" },
{ name = "uvicorn", extras = ["standard"], specifier = ">=0.32.0" }, { name = "uvicorn", extras = ["standard"], specifier = ">=0.32.0" },
] ]
[[package]]
name = "magnetflix-contracts"
version = "0.1.0"
source = { editable = "services/contracts" }
dependencies = [
{ name = "grpcio" },
{ name = "protobuf" },
]
[package.metadata]
requires-dist = [
{ name = "grpcio", specifier = ">=1.83.1" },
{ name = "protobuf", specifier = ">=7.36.2" },
]
[[package]] [[package]]
name = "magnetflix-worker" name = "magnetflix-worker"
version = "0.1.0" version = "0.1.0"
@@ -523,6 +541,7 @@ dependencies = [
{ name = "alembic" }, { name = "alembic" },
{ name = "grpcio" }, { name = "grpcio" },
{ name = "httpx" }, { name = "httpx" },
{ name = "magnetflix-contracts" },
{ name = "protobuf" }, { name = "protobuf" },
{ name = "pydantic" }, { name = "pydantic" },
{ name = "sqlalchemy" }, { name = "sqlalchemy" },
@@ -535,6 +554,7 @@ requires-dist = [
{ name = "alembic", specifier = ">=1.14.0" }, { name = "alembic", specifier = ">=1.14.0" },
{ name = "grpcio", specifier = ">=1.83.1" }, { name = "grpcio", specifier = ">=1.83.1" },
{ name = "httpx", specifier = ">=0.28.0" }, { name = "httpx", specifier = ">=0.28.0" },
{ name = "magnetflix-contracts", editable = "services/contracts" },
{ name = "protobuf", specifier = ">=7.36.1" }, { name = "protobuf", specifier = ">=7.36.1" },
{ name = "pydantic", specifier = ">=2.10.0" }, { name = "pydantic", specifier = ">=2.10.0" },
{ name = "sqlalchemy", specifier = ">=2.0.36" }, { name = "sqlalchemy", specifier = ">=2.0.36" },
@@ -687,17 +707,17 @@ wheels = [
[[package]] [[package]]
name = "protobuf" name = "protobuf"
version = "7.36.1" version = "7.36.2"
source = { registry = "https://pypi.org/simple" } source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/86/73/f66c748df06e7fe24e658eddd600d19c4b40bad836c97ce2d0ad9851fb6b/protobuf-7.36.1.tar.gz", hash = "sha256:d0f6470f0ce2b84e3feaea2d4b816378b37ba4d4aa08a274305373de93e2d524", size = 512499, upload-time = "2026-08-31T22:40:04.667Z" } sdist = { url = "https://files.pythonhosted.org/packages/d9/89/5b8517baa72f84a67b8a307ba953c91057af618bf40bf676f3c03551f8f0/protobuf-7.36.2.tar.gz", hash = "sha256:497d0463ff3316681da6c0b9e8d06cb465d61abce00b613ab42226175644d1bb", size = 512737, upload-time = "2026-09-17T20:07:59.326Z" }
wheels = [ wheels = [
{ url = "https://files.pythonhosted.org/packages/f7/6c/3a54a58f2948b0f485df9ecdd06590f15d0a7abf46a89d50c3de709ff4ff/protobuf-7.36.1-cp310-abi3-macosx_10_9_universal2.whl", hash = "sha256:3cf2ee25d006cee57294a1196ea43b37feb78e0dcd1e8af5c1aeddb777655aca", size = 456046, upload-time = "2026-08-31T22:39:56.865Z" }, { url = "https://files.pythonhosted.org/packages/32/72/98342feb672507c8f3a69e34b4fa8961f608edba5c1a48a6f47156d92cb5/protobuf-7.36.2-cp310-abi3-macosx_10_9_universal2.whl", hash = "sha256:cbc70b17ee27e28894c7fee8bb04be1abead49e936bc70eb60052531eee2079e", size = 456039, upload-time = "2026-09-17T20:07:51.542Z" },
{ url = "https://files.pythonhosted.org/packages/6e/08/9f9548793c771095245c0eeaf0c84b76b16a5ef26158043d456f551344a0/protobuf-7.36.1-cp310-abi3-manylinux2014_aarch64.whl", hash = "sha256:43d3d37b1eb24c113b9b7d02008cac44e423f00b611b7781ae998d7623972969", size = 344226, upload-time = "2026-08-31T22:39:58.263Z" }, { url = "https://files.pythonhosted.org/packages/b6/ea/91fdf7c2b8bbd49cde056f00a9df6773532987e1c00fe2830b895af95c7e/protobuf-7.36.2-cp310-abi3-manylinux2014_aarch64.whl", hash = "sha256:e11e1f0180583a2af89db6a2ecd9e8dc40aa6d2988ca175bfd0e6d12ea72d74e", size = 344219, upload-time = "2026-09-17T20:07:52.914Z" },
{ url = "https://files.pythonhosted.org/packages/fe/51/1bdbd612fa3c51e42ea6f45d05e84dc748ddcd2663e1aa1e89a00a33facd/protobuf-7.36.1-cp310-abi3-manylinux2014_s390x.whl", hash = "sha256:39c518c05586c016d7874ff6079ee115bcec1ea5fbb1d177fbf7867ef4c67e44", size = 357229, upload-time = "2026-08-31T22:39:59.198Z" }, { url = "https://files.pythonhosted.org/packages/17/ab/5fd5f8ece73fad885c5a09aa849b32d70472f954ba3a92d3bb5974ea953b/protobuf-7.36.2-cp310-abi3-manylinux2014_s390x.whl", hash = "sha256:f4fee11ec330d238b34a05c9b675f693c20415d1c5bd7d5320cc2f8a798eb9cf", size = 357223, upload-time = "2026-09-17T20:07:53.985Z" },
{ url = "https://files.pythonhosted.org/packages/22/df/c799fe7a05ef16ba853a59db01f3a2c5f7d0676469589ccc4874f76a2a88/protobuf-7.36.1-cp310-abi3-manylinux2014_x86_64.whl", hash = "sha256:97198b77e369a0abd8e262b8f6c7266c55ddb796a3a12c76d7b8881188ed83aa", size = 343228, upload-time = "2026-08-31T22:40:00.179Z" }, { url = "https://files.pythonhosted.org/packages/db/f3/3996583dd2906297a637af12114deddf7658af6e683fedb83be061983fb5/protobuf-7.36.2-cp310-abi3-manylinux2014_x86_64.whl", hash = "sha256:89f23aa53c24553a2416fd4fd1ec06f74fa42b14b546d8883128813f775bbfd2", size = 343223, upload-time = "2026-09-17T20:07:54.931Z" },
{ url = "https://files.pythonhosted.org/packages/3d/33/d4724ec5d86d496fe4108e220618aa0837ad3423a7af7ccdd9684ccc77c8/protobuf-7.36.1-cp310-abi3-win32.whl", hash = "sha256:0b53ce95272aad50ad25d7ff03373743209822e8ba42ea7fad27d2bee1547d00", size = 443002, upload-time = "2026-08-31T22:40:01.32Z" }, { url = "https://files.pythonhosted.org/packages/fc/1b/dcc64f358fcb51811b58ae40b3d28f820725f116d86487cc20bd4b130701/protobuf-7.36.2-cp310-abi3-win32.whl", hash = "sha256:912c1221170e16c08d1f086762f563dd61ff83c18b5fa6652952dfaded66f728", size = 442998, upload-time = "2026-09-17T20:07:55.826Z" },
{ url = "https://files.pythonhosted.org/packages/db/37/155788a0d8daded960375af604202805308169f9b859419ea0aa370946e2/protobuf-7.36.1-cp310-abi3-win_amd64.whl", hash = "sha256:51139351435d9b43d88a55eaa49fb6f737fbb478fb0cbf2cf694d1a04a9d3363", size = 456518, upload-time = "2026-08-31T22:40:02.494Z" }, { url = "https://files.pythonhosted.org/packages/8a/55/b77bda4e5e5f5971fb51b07663694690e9afdb9402136c16a522bd621cad/protobuf-7.36.2-cp310-abi3-win_amd64.whl", hash = "sha256:a300819d441e078a5608c0d3c709796bb548136058fda017ae51d425b44fd353", size = 456514, upload-time = "2026-09-17T20:07:57.188Z" },
{ url = "https://files.pythonhosted.org/packages/39/ca/c47f91d3cab175b01fd8c4f0d80fdf8613be876cc616e66ad281a59c5ddf/protobuf-7.36.1-py3-none-any.whl", hash = "sha256:7d951e46b3f963d6c264c367c437921de9d5aedd9c3f9612b9077736b4e3ad5c", size = 179813, upload-time = "2026-08-31T22:40:03.54Z" }, { url = "https://files.pythonhosted.org/packages/e4/04/d52c7016b04b6c5108f26691f9d33ec82a9b65d041f1a9c771137693d618/protobuf-7.36.2-py3-none-any.whl", hash = "sha256:bdb3a345d48db958e6ce1f18e508beb0cc981d64f24088427549c866cd039f1e", size = 179806, upload-time = "2026-09-17T20:07:58.211Z" },
] ]
[[package]] [[package]]