Skip to main content

job-service

SDK cliente y runtime para integrarse con un job_service remoto.

Este paquete permite:

  • registrar un servicio consumidor y su manifest de jobs
  • crear ejecuciones remotas
  • reportar progreso, eventos, resultados y errores
  • construir flows reutilizables
  • ejecutar workers con Inngest Connect o con un worker local simple

Instalación

pip install job-service-sdk

API pública principal

from job_service_sdk import (
    JobClientConfig,
    JobDefinitionConfig,
    JobServiceClient,
    JobServiceProvider,
    build_service_client_config,
    bootstrap_job_service_provider,
    initialize_job_service_provider_from_settings,
    job_flow,
    build_job_definition_configs,
    start_job_runtime_from_settings,
    stop_job_runtime_from_settings,
    handler,
    JobWorker,
)

Registrar un servicio y sus jobs

from job_service_sdk import JobClientConfig, JobDefinitionConfig, JobServiceClient

client = JobServiceClient("http://localhost:8001")

client.register_service(
    JobClientConfig(
        client_key="sample-backend",
        display_name="Sample Backend",
        base_url="http://sample-backend:8000",
        healthcheck_url="http://sample-backend:8000/api/v1/health",
    ),
    [
        JobDefinitionConfig(
            client_key="sample-backend",
            job_key="sample_job",
            display_name="Sample Job",
        )
    ],
)

Crear una ejecución

from job_service_sdk import JobServiceClient

client = JobServiceClient("http://localhost:8001")

execution = client.create_execution(
    "sample_job",
    job_input={"sample_key": "sample_value"},
    requested_by_id="sample.user",
    requested_by_display="sample.user@example.com",
)

Reportar progreso y completar

from uuid import UUID

from job_service_sdk import JobServiceClient

client = JobServiceClient("http://localhost:8001")
job_id = UUID("00000000-0000-0000-0000-000000000001")

client.report_progress(
    job_id,
    progress_current=1,
    progress_total=3,
    progress_label="processing",
)

client.complete_execution(
    job_id,
    result={"processed_items": 4},
    result_summary="Job completado",
)

Flow declarativo

from job_service_sdk import JobFlow, job_flow


@job_flow(
    job_key="sample_job",
    display_name="Sample Job",
    description="Ejemplo de flow declarativo",
)
def build_sample_flow() -> JobFlow:
    flow = JobFlow()
    return flow

Corrida programada

cron registra una segunda función de Inngest que solo encola una ejecución con cron_input, así que la corrida programada nace con su fila en el job-service igual que la que se lanza a mano.

cron_guard decide si toca. Se evalúa antes de encolar, de modo que un reloj que corre seguido para una ventana corta no deja ejecuciones vacías en la lista de corridas.

@job_flow(
    job_key="sample_job",
    display_name="Sample Job",
    description="Ejemplo con reloj",
    cron="TZ=America/Bogota 0 * * * *",
    cron_input={"confirm": True},
    cron_guard=is_in_window,
)
def build_sample_flow() -> JobFlow:
    return JobFlow().step("trabajo", do_work)

Worker local

from job_service_sdk import JobServiceClient, JobWorker, handler


@handler("sample_job")
async def sample_handler(job_id, job_input):
    return {"processed_items": 1}


client = JobServiceClient("http://localhost:8001")
worker = JobWorker(client)

Inngest Connect

El paquete incluye helpers para levantar el runtime configurado a partir de settings y definiciones ya registradas.

from job_service_sdk import (
    initialize_job_service_provider_from_settings,
    start_job_runtime_from_settings,
    stop_job_runtime_from_settings,
)

initialize_job_service_provider_from_settings(
    settings,
    definitions_module="sample.jobs_config",
)

await start_job_runtime_from_settings(
    settings,
    definitions_module="sample.jobs_config",
)

await stop_job_runtime_from_settings(settings)

Hoy el runtime soportado es inngest, pero la app consumidora ya no necesita decidir eso directamente.

El supervisor del worker reconecta cuando la conexión con Inngest se cae y también cuando queda muerta sin que inngest lo note. Cada 15 segundos revisa el estado de la conexión y, si la app habla con un Dev Server, le pregunta al servidor por esa conexión en /v0/gql. Tras cuatro revisiones fallidas seguidas cierra el worker, arma uno nuevo y deja un WARNING en el log. Una revisión sin respuesta del servidor no cuenta. is_worker_connected(app_id) responde True solo mientras la conexión está activa y el servidor no la ha dado por perdida.

Metadata

Release files for job-service-sdk 2.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for job-service-sdk 2.4.2
File Size Uploaded Provenance Actions
job_service_sdk-2.4.2.tar.gz 20.7 kB With provenance Details for job_service_sdk-2.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for job-service-sdk 2.4.2
File Interpreter ABI Platform Actions
job_service_sdk-2.4.2-py3-none-any.whl Python 3 none any Details for job_service_sdk-2.4.2-py3-none-any.whl

Total release size: 43.4 kB

Release files / job_service_sdk-2.4.2.tar.gz

Download URL job_service_sdk-2.4.2.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d9550c8e53df7679db3396b6f6bf06cb8ba49c5ac8f0e3878defb12b3cb7bf29
BLAKE2b-256 checksum
How to use checksums
01c9bc38d186244a867da3d1301730a524a1446644e659aa31cbe8f762d5d0de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / job_service_sdk-2.4.2-py3-none-any.whl

Download URL job_service_sdk-2.4.2-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f5f1417fc48c52e5a67b65953151395e447211b06ea06b540ec747df4c4e49c
BLAKE2b-256 checksum
How to use checksums
9b257f8a7832aff83ac0a7756bb6f8d234cf02dc54151a88c196542fff5be3cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for job-service-sdk 2.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for job_service_sdk-2.4.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page