Skip to content

Commit

Permalink
add sample job manifest file, API for read-only view of it
Browse files Browse the repository at this point in the history
  • Loading branch information
onewland committed Sep 9, 2024
1 parent 3fd507e commit 08d33c6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions snuba/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
get_writable_storage,
)
from snuba.datasets.storages.storage_key import StorageKey
from snuba.manual_jobs.manifest_reader import read_jobs_manifest
from snuba.migrations.connect import check_for_inactive_replicas
from snuba.migrations.errors import InactiveClickhouseReplica, MigrationError
from snuba.migrations.groups import MigrationGroup, get_group_readiness_state
Expand Down Expand Up @@ -1264,3 +1265,9 @@ def delete() -> Response:
@check_tool_perms(tools=[AdminTools.DELETE_TOOL])
def deletes_enabled() -> Response:
return make_response(jsonify(deletes_are_enabled()), 200)


@application.route("/job-manifests", methods=["GET"])
@check_tool_perms(tools=[AdminTools.ALL])
def get_job_manifests() -> Response:
return make_response(jsonify(read_jobs_manifest()), 200)
17 changes: 17 additions & 0 deletions snuba/manual_jobs/manifest_reader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from typing import Any, Sequence

import simplejson


class _ManifestReader:
def read(filename) -> Sequence[Any]:
local_root = os.path.dirname(__file__)
with open(os.path.join(local_root, filename)) as stream:
contents = simplejson.loads(stream.read())
assert isinstance(contents, Sequence)
return contents


def read_jobs_manifest() -> Sequence[Any]:
return _ManifestReader.read("run_manifest.json")
1 change: 1 addition & 0 deletions snuba/manual_jobs/run_manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{ "id": "abc1234", "job_type": "ToyJob", "params": { "p1": "value1" } }]

0 comments on commit 08d33c6

Please sign in to comment.