-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(job-runner): enable snuba jobs
command to run from JSON manifest
#6288
Conversation
1160ad8
to
4c3e8a1
Compare
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
4c3e8a1
to
7bd7523
Compare
Snuba Jobs
command now reads JSON manifestSnuba Jobs
command now reads JSON manifest
3865542
to
0d1f3b7
Compare
snuba/cli/jobs.py
Outdated
def run(*, job_name: str, dry_run: bool, pairs: Tuple[str, ...]) -> None: | ||
def run_from_manifest(*, json_manifest: str, job_id: str, dry_run: bool) -> None: | ||
job_specs = ManifestReader.read(json_manifest) | ||
for job_spec in job_specs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe ManifestReader.read can return a map of job id to job spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be fine with that
if job_type_class is None: | ||
raise Exception( | ||
f"Job does not exist. Did you make a file {class_name}.py yet?" | ||
f"Job does not exist. Did you make a file {job_spec.job_type}.py yet?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will make a snake case to camel case later
0d1f3b7
to
06710da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good so far. Is it meant to be a draft PR?
snuba/manual_jobs/manifest_reader.py
Outdated
for content in contents: | ||
content_dict = dict(zip(content[::2], content[1::2])) | ||
job_spec = JobSpec( | ||
job_id=typing.cast(str, content_dict.get("id")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might make sense to do typing.assert_type
here so we reject bad input (instead of just satisfying mypy) https://docs.python.org/3/library/typing.html#typing.assert_type
snuba/cli/jobs.py
Outdated
def run(*, job_name: str, dry_run: bool, pairs: Tuple[str, ...]) -> None: | ||
def run_from_manifest(*, json_manifest: str, job_id: str, dry_run: bool) -> None: | ||
job_specs = ManifestReader.read(json_manifest) | ||
for job_spec in job_specs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be fine with that
Snuba Jobs
command now reads JSON manifestsnuba jobs
command to run from JSON manifest
06710da
to
b024591
Compare
b024591
to
e78bb46
Compare
snuba/manual_jobs/toy_job.py
Outdated
@@ -16,4 +18,10 @@ def _build_query(self) -> str: | |||
return "not dry run query" | |||
|
|||
def execute(self) -> None: | |||
click.echo("executing query `" + self._build_query() + "`") | |||
click.echo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit that doesn't block merge: we shouldn't use click
anything in this namespace because that's specific to CLI usage, and in prod we expect this to be invoked by snuba admin (let's logger.info in a later PR)
snuba/manual_jobs/manifest_reader.py
Outdated
|
||
class _ManifestReader: | ||
|
||
class ManifestReader: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason that you want to make ManifestReader
"public"? I'd prefer to expose as little as possible.
not a blocker for merge
1ab0b23
to
63a3e47
Compare
63a3e47
to
4c906c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is changing 30k lines of code. Are you sure you are committing only the changes relevant to the PR?
…#6320) #6288 Co-authored-by: Rachel Chen <[email protected]>
https://getsentry.atlassian.net/browse/SNS-2872
The SnS engineer will make JSON manifests in the ops repo. This PR enables us to pass in the file path of a JSON manifest file to the
Snuba Jobs
commandNext step will be validation within ManifestReader