-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into volo/eap/virtual_columns
- Loading branch information
Showing
19 changed files
with
438 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,8 @@ else | |
printf "\n${help_result}" | ||
fi | ||
|
||
if [ -n "${ENABLE_HEAPTRACK:-}" ]; then | ||
set -- heaptrack "$@" | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Tuple | ||
|
||
import click | ||
|
||
from snuba.manual_jobs.job_loader import JobLoader | ||
|
||
|
||
@click.group() | ||
def jobs() -> None: | ||
pass | ||
|
||
|
||
@jobs.command() | ||
@click.argument("job_name") | ||
@click.option( | ||
"--dry_run", | ||
default=True, | ||
) | ||
@click.argument("pairs", nargs=-1) | ||
def run(*, job_name: str, dry_run: bool, pairs: Tuple[str, ...]) -> None: | ||
|
||
kwargs = {} | ||
for pair in pairs: | ||
k, v = pair.split("=") | ||
kwargs[k] = v | ||
|
||
job_to_run = JobLoader.get_job_instance(job_name, dry_run, **kwargs) | ||
job_to_run.execute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
from abc import ABC, abstractmethod | ||
from typing import Any, cast | ||
|
||
from snuba.utils.registered_class import RegisteredClass, import_submodules_in_directory | ||
|
||
|
||
class Job(ABC, metaclass=RegisteredClass): | ||
def __init__(self, dry_run: bool, **kwargs: Any) -> None: | ||
self.dry_run = dry_run | ||
for k, v in kwargs.items(): | ||
setattr(self, k, v) | ||
|
||
@abstractmethod | ||
def execute(self) -> None: | ||
pass | ||
|
||
@classmethod | ||
def config_key(cls) -> str: | ||
return cls.__name__ | ||
|
||
@classmethod | ||
def get_from_name(cls, name: str) -> "Job": | ||
return cast("Job", cls.class_from_name(name)) | ||
|
||
|
||
import_submodules_in_directory( | ||
os.path.dirname(os.path.realpath(__file__)), "snuba.manual_jobs" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Any, cast | ||
|
||
from snuba.manual_jobs import Job | ||
|
||
|
||
class JobLoader: | ||
@staticmethod | ||
def get_job_instance(class_name: str, dry_run: bool, **kwargs: Any) -> "Job": | ||
job_type_class = Job.class_from_name(class_name) | ||
if job_type_class is None: | ||
raise Exception( | ||
f"Job does not exist. Did you make a file {class_name}.py yet?" | ||
) | ||
|
||
return cast("Job", job_type_class(dry_run=dry_run, **kwargs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Any | ||
|
||
import click | ||
|
||
from snuba.manual_jobs import Job | ||
|
||
|
||
class ToyJob(Job): | ||
def __init__(self, dry_run: bool, **kwargs: Any): | ||
super().__init__(dry_run, **kwargs) | ||
|
||
def _build_query(self) -> str: | ||
if self.dry_run: | ||
return "dry run query" | ||
else: | ||
return "not dry run query" | ||
|
||
def execute(self) -> None: | ||
click.echo("executing query `" + self._build_query() + "`") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.