id
int64
0
1.29M
original_id
stringlengths
32
32
swhid
stringlengths
100
170
sha1
stringlengths
40
40
repo_name
stringlengths
2
45
repo_group
stringclasses
12 values
filepath
stringlengths
5
153
name
stringlengths
1
14.9k
type
stringclasses
3 values
code
stringlengths
7
2.12M
800
63ee655cb238fd15eb6f5ca4d989f8a7
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=121-126/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
has_infozip_cli()
function
def has_infozip_cli(): try: out = check_output(['unzip', '-h'], stderr=STDOUT).decode() except Exception: return False return "Info-ZIP" in out
801
5599964b1b08afada128a7b9dab09bec
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=20-73/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
root_and_paths(tmpdir_factory)
function
def root_and_paths(tmpdir_factory): root = str(tmpdir_factory.mktemp('example_dir')) def mkfil(*paths): with open(join(root, *paths), mode='wb') as fil: # Write 512 KiB to file fil.write(os.urandom(512 * 2 ** 10)) def mkdir(path): os.mkdir(join(root, path)) def...
802
d8948b5311ca1547a43dba9b65ac628e
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=28-29/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
root_and_paths::mkdir(path)
function
def mkdir(path): os.mkdir(join(root, path))
803
f2734493ba2977661e61790b4c672c4c
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=76-118/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
check(out_dir, root=None, links=False)
function
def check(out_dir, root=None, links=False): assert exists(join(out_dir, "empty_dir")) assert isdir(join(out_dir, "empty_dir")) assert isdir(join(out_dir, "link_to_empty_dir")) assert isdir(join(out_dir, "dir")) assert isfile(join(out_dir, "dir", "one")) assert isfile(join(out_dir, "dir", "two"))...
804
6abf28f536c5e36bae99a605d53140a0
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=23-26/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
root_and_paths::mkfil(*paths)
function
def mkfil(*paths): with open(join(root, *paths), mode='wb') as fil: # Write 512 KiB to file fil.write(os.urandom(512 * 2 ** 10))
805
dd7b39bea2e61602b535fb4f9e27ccac
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=129-134/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
has_tar_cli()
function
def has_tar_cli(): try: check_output(['tar', '-h'], stderr=STDOUT) return True except Exception: return False
806
45ba676239cb789b0fd4b408267f7d8a
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=142-203/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
test_format(tmpdir, format, zip_symlinks, root_and_paths)
function
def test_format(tmpdir, format, zip_symlinks, root_and_paths): if format == 'zip': if zip_symlinks and (on_win or not has_infozip_cli()): pytest.skip("Cannot test zipfile symlink support on this platform") test_symlinks = zip_symlinks else: test_symlinks = not on_win if f...
807
9678f2ec1ee70c445af55ca0185e61e7
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=206-212/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
test_n_threads()
function
def test_n_threads(): assert _parse_n_threads(-1) == cpu_count() assert _parse_n_threads(40) == 40 for n in [-10, 0]: with pytest.raises(CondaPackException): _parse_n_threads(n)
808
ac2c451a1feeee32cd790fc92d26da2f
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=216-248/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
test_format_parallel(tmpdir, format, root_and_paths)
function
def test_format_parallel(tmpdir, format, root_and_paths): # Python 2's bzip dpesn't support reading multipart files :( if format == 'tar.bz2' and PY2: if on_win or not has_tar_cli(): pytest.skip("Unable to test parallel bz2 support on this platform") use_cli_to_extract = True els...
809
f2c664daa2f8131bb5d68715ca81c0d9
swh:1:cnt:50d3356129f0de709b447d552939655a2adf2e45;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=31-42/
3d83aa21211e160c11af790c573fdd8255ec1819
conda-pack
analytics
conda_pack/tests/test_formats.py
root_and_paths::symlink(path, target)
function
def symlink(path, target): target = join(root, target) path = join(root, path) if on_win: # Copy the files instead of symlinking if isdir(target): shutil.copytree(target, path) else: shutil.copyfile(target, path) else: ...
810
bc0d536b098278d704e13b8e318d6af5
swh:1:cnt:336e825c89f5269f2c2cba25404b0abf254bc43e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1-2/
6c447ecd018395b6dfb2551376c957039ec651e2
conda-pack
analytics
testing/test_packages/conda_pack_test_lib1/conda_pack_test_lib1/cli.py
main()
function
def main(): pass
811
bc0d536b098278d704e13b8e318d6af5
swh:1:cnt:336e825c89f5269f2c2cba25404b0abf254bc43e;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-pack.git;lines=1-2/
6c447ecd018395b6dfb2551376c957039ec651e2
conda-pack
analytics
testing/test_packages/conda_pack_test_lib2/conda_pack_test_lib2/cli.py
main()
function
def main(): pass
812
bf58905f204110b4d70fa0228af7414e
swh:1:cnt:76ca0d0beb5cd135bbff60c80aaec326a4b0b043;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=59-67/
fb69387b793631a5b64e881977cb57e52021a837
blunderbuss
analytics
blunderbuss/app.py
BlunderbussApi
type
class BlunderbussApi(Api): """Override the default FlaskRestful API so that we can control the handling of errors, except the very basic HTTPExceptions. """ def error_router(self, original_handler, e): # Override the Flask-Restful error router so that all exceptions # are handled by the...
813
14c1f18a7f15f19edacb3e1d322bfc3d
swh:1:cnt:76ca0d0beb5cd135bbff60c80aaec326a4b0b043;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=64-67/
fb69387b793631a5b64e881977cb57e52021a837
blunderbuss
analytics
blunderbuss/app.py
BlunderbussApi::error_router(self, original_handler, e)
function
def error_router(self, original_handler, e): # Override the Flask-Restful error router so that all exceptions # are handled by the original error_router return original_handler(e)
814
a055e6753f77481d5a0d43cc46b03b3f
swh:1:cnt:76ca0d0beb5cd135bbff60c80aaec326a4b0b043;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=70-138/
fb69387b793631a5b64e881977cb57e52021a837
blunderbuss
analytics
blunderbuss/app.py
create_app(config_name=DEFAULT_FLASK_CONFIG)
function
def create_app(config_name=DEFAULT_FLASK_CONFIG) -> Flask: """Create and configure the Flask app.""" # Configure workflow_utils library to use the PyArrow API # to access HDFS fsspec_use_new_pyarrow_api(True) app = Flask(__name__) app.config.from_object(app_configs[config_name]) app_confi...
815
7dc2b371dd73625bbe6a59c511f62605
swh:1:cnt:a6ad1dcb621cbfb51e8c0a1717a8bb95223122bf;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=7-16/
b543d9272fe4d3bc2ff12a63ef1a86b3a8984281
blunderbuss
analytics
blunderbuss/cache_util.py
cache_key_tstamped(artifact: Artifact)
function
def cache_key_tstamped(artifact: Artifact) -> str: """Constructs a cache key that is a relative path, consisting of artifact ID and current timestamp folder name. :param artifact: Artifact """ tstamp_name = pendulum.now().format("YYYYMMDDHHmmss") # append a trailing slash to denote a directory...
816
e0d940652568a41ab911ba002af4ce1a
swh:1:cnt:a6ad1dcb621cbfb51e8c0a1717a8bb95223122bf;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=19-27/
b543d9272fe4d3bc2ff12a63ef1a86b3a8984281
blunderbuss
analytics
blunderbuss/cache_util.py
cache_key_current(artifact: Artifact)
function
def cache_key_current(artifact: Artifact) -> str: """Constructs a cache key that is a relative path, consisting of artifact ID and folder named "current". :param artifact: Artifact """ # append a trailing slash to denote a directory return str(Path(artifact.name) / "current")
817
280db698cf84a40da9ba1d75fa214772
swh:1:cnt:0f26a6f6f9c281761752a2d607caa80fbc3376c9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=12-28/
00cf8a51e3661e2bc436a6c5e6882bf6cb4e5e20
blunderbuss
analytics
blunderbuss/cache_warmer.py
CacheWarmer
type
class CacheWarmer: # pylint: disable=too-few-public-methods """Orchestrate the synchronization of artifacts.""" def sync(self, artifacts: List[Artifact], force_warmup: bool = False, skip_size_check: bool = False): """Synchronizes the configured deployment.""" for artifact in artifacts: ...
818
8764f7bc91654476cb6b82fb926d60f0
swh:1:cnt:0f26a6f6f9c281761752a2d607caa80fbc3376c9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=15-28/
00cf8a51e3661e2bc436a6c5e6882bf6cb4e5e20
blunderbuss
analytics
blunderbuss/cache_warmer.py
CacheWarmer::sync(self, artifacts: List[Artifact], force_warmup: bool = False, skip_size_check: bool = False)
function
def sync(self, artifacts: List[Artifact], force_warmup: bool = False, skip_size_check: bool = False): """Synchronizes the configured deployment.""" for artifact in artifacts: try: logger.info(f"Synchronizing artifact {artifact.name} {force_warmup=} {skip_size_check=}") ...
819
e348d423249c0d36a3fa4682348d3e23
swh:1:cnt:97f010e0d64eb4f900cacf73df5b6c226905b087;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=1-10/
f2f442d5ad39723ff588c0dc7b5128a022e26463
blunderbuss
analytics
blunderbuss/exceptions.py
BlunderbussError
type
class BlunderbussError(Exception): """Generic Blunderbuss exception, used as a wrapper carrying the actual underlying cause of error. """ def __init__(self, message, errors=None): # Call the base class constructor with the parameters it needs super().__init__(message) self.erro...
820
2cdfd8de5428e41093e89678a61b35ce
swh:1:cnt:97f010e0d64eb4f900cacf73df5b6c226905b087;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=13-16/
f2f442d5ad39723ff588c0dc7b5128a022e26463
blunderbuss
analytics
blunderbuss/exceptions.py
BlunderbussConfigError
type
class BlunderbussConfigError(BlunderbussError): """Errors occurring during parsing of Blunderbuss configuration files.""" pass
821
6137879514f3561619716b4093949fb3
swh:1:cnt:97f010e0d64eb4f900cacf73df5b6c226905b087;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=6-10/
f2f442d5ad39723ff588c0dc7b5128a022e26463
blunderbuss
analytics
blunderbuss/exceptions.py
BlunderbussError::__init__(self, message, errors=None)
function
def __init__(self, message, errors=None): # Call the base class constructor with the parameters it needs super().__init__(message) self.errors = errors
822
fa67db2421ebb7239655412c2d2fc5f1
swh:1:cnt:b32420bdcb3fbc892c5d184ac4e5a33527836fa9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=16-34/
4206f70bf1d40dd0127bfe9de3718abd58a716a8
blunderbuss
analytics
blunderbuss/general_config.py
RepositoryConfiguration
type
class RepositoryConfiguration: """Repository configuration model. Example YAML configuration that maps to this model class (self.name would be set to "test-hdfs-sync" in this case): repositories: test-hdfs-sync: url: "https://gitlab.wikimedia.org/amastilovic/test-hdfs-sync-project" ...
823
06feaa4dbe7e467185a6c4b3eef541c6
swh:1:cnt:b32420bdcb3fbc892c5d184ac4e5a33527836fa9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=37-56/
4206f70bf1d40dd0127bfe9de3718abd58a716a8
blunderbuss
analytics
blunderbuss/general_config.py
GeneralConfiguration
type
class GeneralConfiguration: """General configuration model class, basically a placeholder for repositories and target artifacts. Besides those two collections, it also supports any general configuration settings through **kwargs """ def __init__( self, **kwargs, ): ...
824
a44643a36f17f733607bc9574eb4d40a
swh:1:cnt:b32420bdcb3fbc892c5d184ac4e5a33527836fa9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=28-31/
4206f70bf1d40dd0127bfe9de3718abd58a716a8
blunderbuss
analytics
blunderbuss/general_config.py
RepositoryConfiguration::__init__(self, name: str, **kwargs)
function
def __init__(self, name: str, **kwargs): self.name: str = name self.url: str = kwargs["url"] self.branch: str = kwargs.get("branch", DEFAULT_BRANCH)
825
a40912b9254d786923d35d677718e04e
swh:1:cnt:b32420bdcb3fbc892c5d184ac4e5a33527836fa9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=54-56/
4206f70bf1d40dd0127bfe9de3718abd58a716a8
blunderbuss
analytics
blunderbuss/general_config.py
GeneralConfiguration::__repr__(self)
function
def __repr__(self): attrs = dir(self) return repr(f"Configuration general vars: {attrs}")
826
4c4bbcc65b9591a6a948030a8523b837
swh:1:cnt:b32420bdcb3fbc892c5d184ac4e5a33527836fa9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=45-52/
4206f70bf1d40dd0127bfe9de3718abd58a716a8
blunderbuss
analytics
blunderbuss/general_config.py
GeneralConfiguration::__init__( self, **kwargs, )
function
def __init__( self, **kwargs, ): self.repositories_local_path: str = DEFAULT_REPO_LOCAL_PATH for config_name, config_value in kwargs.items(): setattr(self, config_name, config_value)
827
06d4eb7c8e84ca7c55d49047a0057d04
swh:1:cnt:b32420bdcb3fbc892c5d184ac4e5a33527836fa9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=59-65/
4206f70bf1d40dd0127bfe9de3718abd58a716a8
blunderbuss
analytics
blunderbuss/general_config.py
load_config()
function
def load_config() -> GeneralConfiguration: """Parse configuration files and construct a configuration model object. """ config = yaml.safe_load(Path(CONFIG_FILENAME).read_text(encoding="utf-8")) return GeneralConfiguration(**config["general"])
828
58a239251e2a6829388e2448b5fa9409
swh:1:cnt:b32420bdcb3fbc892c5d184ac4e5a33527836fa9;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=33-34/
4206f70bf1d40dd0127bfe9de3718abd58a716a8
blunderbuss
analytics
blunderbuss/general_config.py
RepositoryConfiguration::__repr__(self)
function
def __repr__(self): return repr("RepositoryConfiguration " + f"{self.name} {self.url=} {self.branch=}")
829
946e7015c5d08ac09bb24910054358f4
swh:1:cnt:f3a7ec6bc3fe9692a24e37e53d98f115cba72428;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=11-23/
971caee4530c5a3f8e5e8e205ab280f01d6fc604
blunderbuss
analytics
blunderbuss/orchestrator.py
Orchestrator
type
class Orchestrator: # pylint: disable=too-few-public-methods """Orchestrate the synchronization of artifacts.""" def sync(self, artifacts: List[Artifact]): """Synchronizes the configured deployment.""" for artifact in artifacts: try: logger.info(f"Synchronizing art...
830
5880bf2fde4e6a84fbcc272b840c70da
swh:1:cnt:f3a7ec6bc3fe9692a24e37e53d98f115cba72428;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=14-23/
971caee4530c5a3f8e5e8e205ab280f01d6fc604
blunderbuss
analytics
blunderbuss/orchestrator.py
Orchestrator::sync(self, artifacts: List[Artifact])
function
def sync(self, artifacts: List[Artifact]): """Synchronizes the configured deployment.""" for artifact in artifacts: try: logger.info(f"Synchronizing artifact {artifact}") artifact.cache_put(force=True) except Exception as e: logger...
831
8aa3c4e1e3d353ad3fe00210286267f5
swh:1:cnt:f3a318b0e48ecf261d8f15d93af3835ac38d57cd;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=21-200/
0bc2f715581aaf1e2e59c3e0122d54cf07c3aa77
blunderbuss
analytics
blunderbuss/repository.py
Repository
type
class Repository: """Utility class for Git repository manipulation.""" def __init__( self, local_path: str, ): if not local_path: raise BlunderbussError("Local disk repository path configuration missing") self.local_path: Path = Path(local_path) def get_loc...
832
36ee23199c096debb66ecfaf8c57bd0f
swh:1:cnt:f3a318b0e48ecf261d8f15d93af3835ac38d57cd;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=33-37/
0bc2f715581aaf1e2e59c3e0122d54cf07c3aa77
blunderbuss
analytics
blunderbuss/repository.py
Repository::get_local_path(self, repository_config: RepositoryConfiguration)
function
def get_local_path(self, repository_config: RepositoryConfiguration) -> Path: """Builds an absolute path to the checked-out repository directory on local disk. """ return self.local_path / repository_config.name
833
34859672fdfdecf3a0adb97cc10e23db
swh:1:cnt:f3a318b0e48ecf261d8f15d93af3835ac38d57cd;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=91-103/
0bc2f715581aaf1e2e59c3e0122d54cf07c3aa77
blunderbuss
analytics
blunderbuss/repository.py
Repository::find_artifact_files( self, repo_config: RepositoryConfiguration, artifacts_fname_globs: List[str], )
function
def find_artifact_files( self, repo_config: RepositoryConfiguration, artifacts_fname_globs: List[str], ) -> List[Path]: """Search the repository tree to find all ARTIFACTS_FILE paths.""" local_repo_dir = self.get_local_path(repo_config) collected_paths: set[Path] = s...
834
58ac19dd7a715cdc99b68f659f7bf54b
swh:1:cnt:f3a318b0e48ecf261d8f15d93af3835ac38d57cd;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=24-31/
0bc2f715581aaf1e2e59c3e0122d54cf07c3aa77
blunderbuss
analytics
blunderbuss/repository.py
Repository::__init__( self, local_path: str, )
function
def __init__( self, local_path: str, ): if not local_path: raise BlunderbussError("Local disk repository path configuration missing") self.local_path: Path = Path(local_path)
835
d64237172380c761a48d742e62b5e8d3
swh:1:cnt:f3a318b0e48ecf261d8f15d93af3835ac38d57cd;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=39-89/
0bc2f715581aaf1e2e59c3e0122d54cf07c3aa77
blunderbuss
analytics
blunderbuss/repository.py
Repository::refresh( self, repo_config: RepositoryConfiguration, hard_reset: bool = False, )
function
def refresh( self, repo_config: RepositoryConfiguration, hard_reset: bool = False, ): """Refreshes the local clone directory of a given configured repository. If 'hard_reset' argument is set to True, it will wipe the local cloned directory before proceeding. ...
836
351d9540e30907b47fb423ec227e8793
swh:1:cnt:f3a318b0e48ecf261d8f15d93af3835ac38d57cd;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=105-187/
0bc2f715581aaf1e2e59c3e0122d54cf07c3aa77
blunderbuss
analytics
blunderbuss/repository.py
Repository::get_artifacts( self, general_config: GeneralConfiguration, repo_config: RepositoryConfiguration, artifact_files: Optional[List[Path]] = None, artifact_prefix: Optional[Path] = None, blunderbuss_bugler_env_vars: Optional[dict[str, str]] = None, )
function
def get_artifacts( self, general_config: GeneralConfiguration, repo_config: RepositoryConfiguration, artifact_files: Optional[List[Path]] = None, artifact_prefix: Optional[Path] = None, blunderbuss_bugler_env_vars: Optional[dict[str, str]] = None, ) -> List[Artifact]:...
837
8f8793f63ac21988557ce22a0c1cf712
swh:1:cnt:f3a318b0e48ecf261d8f15d93af3835ac38d57cd;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=189-200/
0bc2f715581aaf1e2e59c3e0122d54cf07c3aa77
blunderbuss
analytics
blunderbuss/repository.py
Repository::bootstrap(self, reset: bool = False)
function
def bootstrap(self, reset: bool = False): """Bootstraps all configured repositories. If 'reset' argument is True, it will delete the local directories of all configured repositories. """ # ensure local repository directory exists self.local_path.mkdir(parents=True, exis...
838
abbf2b4f505a550b8b5247f3af1eb4bd
swh:1:cnt:e81985c3d7fbcba92eb88d17689535720a5b7827;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=6-12/
c51f7274650ab903e11ea36b9bc5b9a2dc22071b
blunderbuss
analytics
blunderbuss/config/errors.py
forbidden(e)
function
def forbidden(e): if request.accept_mimetypes.accept_json and not request.accept_mimetypes.accept_html: response = jsonify({"error": "Forbidden"}) response.status_code = 403 return response return render_template("403.html"), 403
839
448327756af08901994411eb688a3d23
swh:1:cnt:e81985c3d7fbcba92eb88d17689535720a5b7827;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=15-21/
c51f7274650ab903e11ea36b9bc5b9a2dc22071b
blunderbuss
analytics
blunderbuss/config/errors.py
page_not_found(e)
function
def page_not_found(e): if request.accept_mimetypes.accept_json and not request.accept_mimetypes.accept_html: response = jsonify({"error": "Not found"}) response.status_code = 404 return response return render_template("404.html"), 404
840
5413ed56ba12d1997c99f0a094554378
swh:1:cnt:e81985c3d7fbcba92eb88d17689535720a5b7827;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=24-31/
c51f7274650ab903e11ea36b9bc5b9a2dc22071b
blunderbuss
analytics
blunderbuss/config/errors.py
internal_server_error(e)
function
def internal_server_error(e): if request.accept_mimetypes.accept_json and not request.accept_mimetypes.accept_html: stacktrace = "".join(traceback.TracebackException.from_exception(e).format()) response = jsonify({"error": "Internal server error", "stacktrace": stacktrace}) response.status_c...
841
0b31b3a75454c8008e056f8d396c5c9e
swh:1:cnt:0cf71aa343f046f476eb1f66552776c22d3be591;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=7-16/
de6619ec91ad5994b124f4a56a8c50ebee81206d
blunderbuss
analytics
blunderbuss/config/settings.py
strtobool(value: str)
function
def strtobool(value: str) -> bool: """Converts a string representation of a boolean into an actual bool value """ value = value.lower() if value in ("y", "yes", "on", "1", "true", "t"): return True return False
842
7cef37feefc9353e742d1c4344b6ce1e
swh:1:cnt:0cf71aa343f046f476eb1f66552776c22d3be591;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=61-63/
de6619ec91ad5994b124f4a56a8c50ebee81206d
blunderbuss
analytics
blunderbuss/config/settings.py
ProductionConfig::init_app(cls, app)
function
def init_app(cls, app): """Special production initialization procedure goes here.""" Config.init_app(app)
843
5529a46868f418d2dbe801378f8efa4c
swh:1:cnt:0cf71aa343f046f476eb1f66552776c22d3be591;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=39-42/
de6619ec91ad5994b124f4a56a8c50ebee81206d
blunderbuss
analytics
blunderbuss/config/settings.py
Config::init_app(app)
function
def init_app(app): """Override this method if a particular configuration requires special initialization steps. """
844
c1cbc3d3817ea152bde85bf973b2299d
swh:1:cnt:0cf71aa343f046f476eb1f66552776c22d3be591;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=19-42/
de6619ec91ad5994b124f4a56a8c50ebee81206d
blunderbuss
analytics
blunderbuss/config/settings.py
Config
type
class Config: # pylint: disable=too-few-public-methods """Basic Flask app configuration object.""" SECRET_KEY = os.environ.get("SECRET_KEY") or "lq4kfwFidVbDxaKL" HOST = os.getenv("FLASK_RUN_HOST", "http://localhost") PORT = os.getenv("FLASK_RUN_PORT", "8090") DEBUG = False TESTING = False ...
845
88cffb9c0c46495b95682600fc610c36
swh:1:cnt:0cf71aa343f046f476eb1f66552776c22d3be591;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=57-63/
de6619ec91ad5994b124f4a56a8c50ebee81206d
blunderbuss
analytics
blunderbuss/config/settings.py
ProductionConfig
type
class ProductionConfig(Config): # pylint: disable=too-few-public-methods """Production environment configuration settings.""" @classmethod def init_app(cls, app): """Special production initialization procedure goes here.""" Config.init_app(app)
846
8a217945c5f750025ddafac510e04537
swh:1:cnt:0cf71aa343f046f476eb1f66552776c22d3be591;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=51-54/
de6619ec91ad5994b124f4a56a8c50ebee81206d
blunderbuss
analytics
blunderbuss/config/settings.py
TestingConfig
type
class TestingConfig(Config): # pylint: disable=too-few-public-methods """Testing environment configuration settings.""" TESTING = True
847
3f21dcc72cb9ce6bf180e85fbfcf4cfa
swh:1:cnt:0cf71aa343f046f476eb1f66552776c22d3be591;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=45-48/
de6619ec91ad5994b124f4a56a8c50ebee81206d
blunderbuss
analytics
blunderbuss/config/settings.py
DevelopmentConfig
type
class DevelopmentConfig(Config): # pylint: disable=too-few-public-methods """Development/debugging configuration settings.""" DEBUG = True
848
751f0c84487a17bce2523c66ee82949e
swh:1:cnt:878a4f15c8cb5983ed849f580e01ce5e7cc8d38c;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=18-28/
cbe1c229829d261a31e572f7dd9471090090eb8c
blunderbuss
analytics
blunderbuss/config/util.py
render_config_values(config_dict: dict, context: dict)
function
def render_config_values(config_dict: dict, context: dict) -> dict: """Recursively render all string values in a nested dict using Jinja2.""" rendered = {} for key, value in config_dict.items(): if isinstance(value, dict): rendered[key] = render_config_values(value, context) elif...
849
0a509c31b420fae42ab97a130a5d9f9c
swh:1:cnt:878a4f15c8cb5983ed849f580e01ce5e7cc8d38c;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=94-108/
cbe1c229829d261a31e572f7dd9471090090eb8c
blunderbuss
analytics
blunderbuss/config/util.py
parse_configs(config_files: List[Path])
function
def parse_configs(config_files: List[Path]) -> dict[Any, Any]: """Parses the artifacts YAML configuration files into a unified dictionary of key-value pairs. """ collected_config: dict[Any, Any] = {} for config_fpath in config_files: logger.info(f"Loading config file {config_fpath}") ...
850
18e321e0edb226bfa760834fffbbbc25
swh:1:cnt:878a4f15c8cb5983ed849f580e01ce5e7cc8d38c;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=31-91/
cbe1c229829d261a31e572f7dd9471090090eb8c
blunderbuss
analytics
blunderbuss/config/util.py
load_artifacts_config(config, blunderbuss_bugler_env_vars: Optional[Dict[str, str]] = None)
function
def load_artifacts_config(config, blunderbuss_bugler_env_vars: Optional[Dict[str, str]] = None): """Loads artifact source and caches configuration.""" # If a config dict, just use it. if isinstance(config, dict): pass # Else load the config from yaml config files. else: config = yam...
851
38aa1d7d676873e61b1857c03980a98b
swh:1:cnt:9ba053854d0c8525ef033cc9fbfa58aa362e7e43;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=24-56/
1d218d6cd1c23bc43066eee701566892c226247d
blunderbuss
analytics
blunderbuss/resources/cache_warmup.py
warmup_cache_task( general_config: GeneralConfiguration, repo_config: RepositoryConfiguration, repository: Repository, cache_warmer: CacheWarmer, instances: List[str], hard_reset: bool, force_warmup: bool, skip_size_check: bool, blunderbuss_bugler_env_vars: dict[str, str] | None = No...
function
def warmup_cache_task( general_config: GeneralConfiguration, repo_config: RepositoryConfiguration, repository: Repository, cache_warmer: CacheWarmer, instances: List[str], hard_reset: bool, force_warmup: bool, skip_size_check: bool, blunderbuss_bugler_env_vars: dict[str, str] | None ...
852
e3b72fec342cdfb26ebbd0207c594c57
swh:1:cnt:9ba053854d0c8525ef033cc9fbfa58aa362e7e43;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=75-116/
1d218d6cd1c23bc43066eee701566892c226247d
blunderbuss
analytics
blunderbuss/resources/cache_warmup.py
CacheWarmupResource::post(self, repo_label: str)
function
def post(self, repo_label: str): try: hard_reset = request.args.get("hard_reset", DEFAULT_HARD_RESET, type=int) == 1 force_warmup = request.args.get("force_warmup", DEFAULT_FORCE_WARMUP, type=int) == 1 skip_size_check = request.args.get("skip_size_check", DEFAULT_SKIP_SIZE_CH...
853
da56f98b4b3b7e73df6fe4d5bd2ac878
swh:1:cnt:9ba053854d0c8525ef033cc9fbfa58aa362e7e43;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=62-73/
1d218d6cd1c23bc43066eee701566892c226247d
blunderbuss
analytics
blunderbuss/resources/cache_warmup.py
CacheWarmupResource::__init__(self, app: Flask, config: GeneralConfiguration)
function
def __init__(self, app: Flask, config: GeneralConfiguration): self.app = app self.config = config self.cache_warmer = CacheWarmer() self.repository = Repository(config.repositories_local_path) # Define parser and request args self.parser = reqparse.RequestParser() ...
854
12b896d38e227bcdb30347dec7537d1a
swh:1:cnt:9ba053854d0c8525ef033cc9fbfa58aa362e7e43;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=59-116/
1d218d6cd1c23bc43066eee701566892c226247d
blunderbuss
analytics
blunderbuss/resources/cache_warmup.py
CacheWarmupResource
type
class CacheWarmupResource(Resource): # pylint: disable=too-few-public-methods """Flask resource responsible for handling the cache warmup REST API command.""" def __init__(self, app: Flask, config: GeneralConfiguration): self.app = app self.config = config self.cache_warmer = CacheWarm...
855
e8282af58e80d857efe912aa9a7e8a8a
swh:1:cnt:05306515ea8dca937bffdb48e67a099ddc0b3709;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=5-16/
793446441d84a85d1015b31b910f8bc8608915a1
blunderbuss
analytics
blunderbuss/resources/health.py
HealthcheckResource
type
class HealthcheckResource(Resource): # pylint: disable=too-few-public-methods """Simple health check resource.""" def __init__(self, app: Flask): self.app: Flask = app def get(self): """Healthcheck endpoint. Simply return a 200 http response. """ return "OK"
856
35f50d63e75cfa6e89f31385746be181
swh:1:cnt:05306515ea8dca937bffdb48e67a099ddc0b3709;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=8-9/
793446441d84a85d1015b31b910f8bc8608915a1
blunderbuss
analytics
blunderbuss/resources/health.py
HealthcheckResource::__init__(self, app: Flask)
function
def __init__(self, app: Flask): self.app: Flask = app
857
da965683462d3d2e76d430ffc5ef320e
swh:1:cnt:05306515ea8dca937bffdb48e67a099ddc0b3709;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=11-16/
793446441d84a85d1015b31b910f8bc8608915a1
blunderbuss
analytics
blunderbuss/resources/health.py
HealthcheckResource::get(self)
function
def get(self): """Healthcheck endpoint. Simply return a 200 http response. """ return "OK"
858
9ebbd58700050fda75471ff4b3254732
swh:1:cnt:f14b251cd656c76655f6c96c5405cb43bcc150df;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=7-17/
5a67fa3ee8101b78990c56d94703bb090f7529a6
blunderbuss
analytics
blunderbuss/resources/release.py
ReleaseResource
type
class ReleaseResource(Resource): def __init__(self, **kwargs): pass def get(self, release_label): """Not implemented as of yet. Pull a release artifact and publish to HDFS or other target(s) """ return jsonify({"release": release_label})
859
3236e12a21c98d02fca4d39466ec4450
swh:1:cnt:f14b251cd656c76655f6c96c5405cb43bcc150df;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=9-10/
5a67fa3ee8101b78990c56d94703bb090f7529a6
blunderbuss
analytics
blunderbuss/resources/release.py
ReleaseResource::__init__(self, **kwargs)
function
def __init__(self, **kwargs): pass
860
0fd7295026e859159c366222afde96cf
swh:1:cnt:f14b251cd656c76655f6c96c5405cb43bcc150df;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=12-17/
5a67fa3ee8101b78990c56d94703bb090f7529a6
blunderbuss
analytics
blunderbuss/resources/release.py
ReleaseResource::get(self, release_label)
function
def get(self, release_label): """Not implemented as of yet. Pull a release artifact and publish to HDFS or other target(s) """ return jsonify({"release": release_label})
861
a58aa3af5120d94c97e1af7b32bc29ad
swh:1:cnt:e67ee22f95359b6a79010ca5dc83d7a93d9e9784;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=16-36/
a8bca9913969796ed6f97bd5c8e892c7b7d8ce57
blunderbuss
analytics
blunderbuss/resources/repository_huey.py
sync_repository_task( general_config: GeneralConfiguration, repo_config: RepositoryConfiguration, repository: Repository, orchestrator: Orchestrator, hard_reset: bool, )
function
def sync_repository_task( general_config: GeneralConfiguration, repo_config: RepositoryConfiguration, repository: Repository, orchestrator: Orchestrator, hard_reset: bool, ) -> str: """Perform the synchronization of artifacts in the repository in a background Huey task. """ repositor...
862
aa3a34e2815555fcf945197b2a1aaff5
swh:1:cnt:e67ee22f95359b6a79010ca5dc83d7a93d9e9784;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=53-83/
a8bca9913969796ed6f97bd5c8e892c7b7d8ce57
blunderbuss
analytics
blunderbuss/resources/repository_huey.py
RepositoryResource::post(self, repo_label: str)
function
def post(self, repo_label: str): """Handling of POST requests.""" self.app.logger.info(f"Requested synchronization of {repo_label}") # hard reset will clear the local repo directory # before pulling the latest changes hard_reset = request.args.get("hard_reset", DEFAULT_HARD_RESE...
863
a65e1d24fb2c875694fd56fcd70e96a5
swh:1:cnt:e67ee22f95359b6a79010ca5dc83d7a93d9e9784;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=42-51/
a8bca9913969796ed6f97bd5c8e892c7b7d8ce57
blunderbuss
analytics
blunderbuss/resources/repository_huey.py
RepositoryResource::__init__(self, app: Flask, config: GeneralConfiguration)
function
def __init__(self, app: Flask, config: GeneralConfiguration): self.app = app self.config = config self.orchestrator = Orchestrator() self.repository = Repository(config.repositories_local_path) # Define parser and request args self.parser = reqparse.RequestParser() ...
864
dd804261f768e7526313fbb5bac31b3d
swh:1:cnt:e67ee22f95359b6a79010ca5dc83d7a93d9e9784;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=39-83/
a8bca9913969796ed6f97bd5c8e892c7b7d8ce57
blunderbuss
analytics
blunderbuss/resources/repository_huey.py
RepositoryResource
type
class RepositoryResource(Resource): """Flask resource responsible for handling repository REST API commands.""" def __init__(self, app: Flask, config: GeneralConfiguration): self.app = app self.config = config self.orchestrator = Orchestrator() self.repository = Repository(confi...
865
50e1cf633f358535c8174a54517d6fa5
swh:1:cnt:391920bcb2a53169a9d34a223e6a3abcc03e63a2;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=9-42/
070613142aa7553c7be942886255064a74867502
blunderbuss
analytics
blunderbuss/resources/tasks.py
TaskResource
type
class TaskResource(Resource): """Resource to retrieve the status and output of tasks running in background.""" def __init__( self, app: Flask, config: GeneralConfiguration, ): self.app: Flask = app self.config: GeneralConfiguration = config def get(self, task_id...
866
882e21f92b1ab1058151579b8cde2d6f
swh:1:cnt:391920bcb2a53169a9d34a223e6a3abcc03e63a2;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=12-18/
070613142aa7553c7be942886255064a74867502
blunderbuss
analytics
blunderbuss/resources/tasks.py
TaskResource::__init__( self, app: Flask, config: GeneralConfiguration, )
function
def __init__( self, app: Flask, config: GeneralConfiguration, ): self.app: Flask = app self.config: GeneralConfiguration = config
867
f562224488b5ebe05637582db0dce58d
swh:1:cnt:391920bcb2a53169a9d34a223e6a3abcc03e63a2;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=20-42/
070613142aa7553c7be942886255064a74867502
blunderbuss
analytics
blunderbuss/resources/tasks.py
TaskResource::get(self, task_id: str)
function
def get(self, task_id: str): """Process GET request of this resource. Retrieve the status of a given Huey task ID, and populate the resulting JSON dictionary accordingly. """ retval = { "ready": False, "success": False, "result": None, ...
868
a07f11b24b258995211a843bb8628989
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=11-26/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
PatchMixin
type
class PatchMixin: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.mocks: MutableMapping[str, Any] = defaultdict(lambda: None) def patch(self, target, **kwargs): """Patches a given target, opens up the patching context, and sets up the context closure...
869
a1dcb6505d038976af5ca6323f463cd2
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=29-145/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase
type
class APITestCase(PatchMixin, unittest.TestCase): """Test the REST API endpoints. Note that PatchMixin has to go first in inheritance list in order for its constructor to be properly called. """ def constructArtifacts(self): self.default_config = {} default_source = { "...
870
95d7607c0d3cd1f40d6c86bd1e7690dd
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=13-15/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
PatchMixin::__init__(self, *args, **kwargs)
function
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.mocks: MutableMapping[str, Any] = defaultdict(lambda: None)
871
ff65e7569e5f09c2c3a833a926951b1f
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=89-91/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase::tearDown(self)
function
def tearDown(self): self.huey.immediate = False self.app_context.pop()
872
70fca9ca47976d65d04406966d3a18f1
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=100-104/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase::test_404(self)
function
def test_404(self): response = self.client.get("/wrong/url", headers=self.get_api_headers("username", "password")) self.assertEqual(response.status_code, 404) json_response = json.loads(response.get_data(as_text=True)) self.assertEqual(json_response["error"], "Not found")
873
9eb997537c25c3dc39a6b48cef508274
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=17-26/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
PatchMixin::patch(self, target, **kwargs)
function
def patch(self, target, **kwargs): """Patches a given target, opens up the patching context, and sets up the context closure on cleanup. """ mock_name = kwargs["mock_name"] p = mock.patch(target, **kwargs) mock_obj = p.start() self.mocks[mock_name] = mock_obj ...
874
df355fb0065cfac7f0a006ebc2b93195
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=45-87/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase::setUp(self)
function
def setUp(self): """Run before each test case.""" self.patch("blunderbuss.orchestrator.Orchestrator", **{"mock_name": "orchestrator_mock"}) self.patch("blunderbuss.repository.Repository", **{"mock_name": "repos_mock"}) self.constructArtifacts() artifact_sql = Artifact.factory( ...
875
45730a9640210ef9653f203a680cc797
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=36-43/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase::constructArtifacts(self)
function
def constructArtifacts(self): self.default_config = {} default_source = { "url": { "class_name": "workflow_utils.artifact.FsArtifactSource", } } self.default_config["artifact_sources"] = default_source
876
90159fbced447990e0a63704458c2a55
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=93-98/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase::get_api_headers(self, username, password)
function
def get_api_headers(self, username, password): return { "Authorization": "Basic " + b64encode((username + ":" + password).encode("utf-8")).decode("utf-8"), "Accept": "application/json", "Content-Type": "application/json", }
877
8b40f5928c0d225cd20d834606f77198
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=106-110/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase::test_500(self)
function
def test_500(self): response = self.client.get("/repository/non-existent", headers={"Accept": "application/json"}) self.assertEqual(response.status_code, 500) json_response = json.loads(response.get_data(as_text=True)) self.assertEqual(json_response["error"], "Internal server error")
878
37a8947812f2ea99b499a9877dd96804
swh:1:cnt:80977c9e769a466349e2e3bdd20779c38345f449;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=112-145/
72576e8cf7499b5089d82760240e212f44940e08
blunderbuss
analytics
tests/test_api.py
APITestCase::test_200(self)
function
def test_200(self): repo_name = "test-hdfs-sync" payload = { "url": "https://gitlab.wikimedia.org/amastilovic/test-hdfs-sync-project", "branch": "main", } response = self.client.post( f"/repository/{repo_name}", json=payload, h...
879
09a17f597d431cba4842fd4996ad5e59
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=7-38/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
RenderConfigValuesTestCase
type
class RenderConfigValuesTestCase(unittest.TestCase): """Test the Jinja2 rendering of artifact source config values.""" def test_render_flat_string(self): config = {"key": "{{ blunderbuss_bugler_env_vars.MY_VAR }}"} context = {"blunderbuss_bugler_env_vars": {"MY_VAR": "hello"}} result = ...
880
92d5b8db266a6d0cb263c90645487e82
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=41-114/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
LoadArtifactsConfigRenderingTestCase
type
class LoadArtifactsConfigRenderingTestCase(unittest.TestCase): """Test that load_artifacts_config renders artifact_sources with Jinja2.""" @mock.patch("blunderbuss.config.util.instantiate_all") def test_rendering_applied_before_instantiation(self, mock_instantiate_all): mock_instantiate_all.return_...
881
1b1d46bd7527e863a4b96718e3d5281f
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=117-168/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
LoadArtifactsCacheRenderingTestCase
type
class LoadArtifactsCacheRenderingTestCase(unittest.TestCase): """Test that load_artifacts_config renders artifact_caches with Jinja2.""" @mock.patch("blunderbuss.config.util.instantiate_all") def test_cache_rendering_applied_before_instantiation(self, mock_instantiate_all): mock_instantiate_all.sid...
882
45142720945c7aa5514ef95abf8b9bbd
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=10-14/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
RenderConfigValuesTestCase::test_render_flat_string(self)
function
def test_render_flat_string(self): config = {"key": "{{ blunderbuss_bugler_env_vars.MY_VAR }}"} context = {"blunderbuss_bugler_env_vars": {"MY_VAR": "hello"}} result = render_config_values(config, context) self.assertEqual(result["key"], "hello")
883
e599b6129a4fdb5f3b1cd5148de81732
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=95-114/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
LoadArtifactsConfigRenderingTestCase::test_no_rendering_when_env_vars_empty(self, mock_instantiate_all)
function
def test_no_rendering_when_env_vars_empty(self, mock_instantiate_all): mock_instantiate_all.return_value = {"url": mock.MagicMock()} config = { "artifact_sources": { "url": { "class_name": "workflow_utils.artifact.FsArtifactSource", "b...
884
c1b2395c04ce8edeaed063948014281b
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=73-92/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
LoadArtifactsConfigRenderingTestCase::test_no_rendering_when_env_vars_none(self, mock_instantiate_all)
function
def test_no_rendering_when_env_vars_none(self, mock_instantiate_all): mock_instantiate_all.return_value = {"url": mock.MagicMock()} config = { "artifact_sources": { "url": { "class_name": "workflow_utils.artifact.FsArtifactSource", "ba...
885
aac6c095326efd10c998b61ba4c5c751
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=16-38/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
RenderConfigValuesTestCase::test_render_nested_mixed_values(self)
function
def test_render_nested_mixed_values(self): config = { "source_a": { "class_name": "some.Class", "base_uri": "{{ blunderbuss_bugler_env_vars.SCHEME }}://{{ blunderbuss_bugler_env_vars.HOST }}/data", }, "plain_key": "plain_value", "ne...
886
cd71d3ae540b20619addfff45d6de374
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=45-70/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
LoadArtifactsConfigRenderingTestCase::test_rendering_applied_before_instantiation(self, mock_instantiate_all)
function
def test_rendering_applied_before_instantiation(self, mock_instantiate_all): mock_instantiate_all.return_value = {"url": mock.MagicMock()} config = { "artifact_sources": { "url": { "class_name": "workflow_utils.artifact.FsArtifactSource", ...
887
8523c25696ed7c7faaa153f667b45051
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=121-144/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
LoadArtifactsCacheRenderingTestCase::test_cache_rendering_applied_before_instantiation(self, mock_instantiate_all)
function
def test_cache_rendering_applied_before_instantiation(self, mock_instantiate_all): mock_instantiate_all.side_effect = [{"url": mock.MagicMock()}, {"hdfs": mock.MagicMock()}] config = { "artifact_sources": {"url": {"class_name": "workflow_utils.artifact.FsArtifactSource"}}, "defa...
888
ad0a26b05398a72744ca24e8af7431d8
swh:1:cnt:4c7d3e8916f57f13515567287941c05ad8ab1ad3;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss.git;lines=147-168/
0db9aaba0036347e953d686c898b8ccf52e76d07
blunderbuss
analytics
tests/test_render_config.py
LoadArtifactsCacheRenderingTestCase::test_no_cache_rendering_when_env_vars_none(self, mock_instantiate_all)
function
def test_no_cache_rendering_when_env_vars_none(self, mock_instantiate_all): mock_instantiate_all.side_effect = [{"url": mock.MagicMock()}, {"hdfs": mock.MagicMock()}] config = { "artifact_sources": {"url": {"class_name": "workflow_utils.artifact.FsArtifactSource"}}, "default_art...
889
c6ab5453bfc3462bc859876e920efea7
swh:1:cnt:3ae99bb6522dd939c2caee8a1ac2ed4103fb2ad3;origin=https://gerrit.wikimedia.org/r/analytics/multimedia.git;lines=56-77/
57ca6ed4b094ea4299b70a3b34a615e38c6ed5ea
multimedia
analytics
generate.py
generate(folder, wiki, metric=None)
function
def generate(folder, wiki, metric=None): replacement = '' if wiki != 'global': replacement = 'wiki = \'' + wiki + '\' AND' sql = open( os.path.dirname(os.path.realpath(__file__)) + '/' + folder + '/template.sql').read() sql = sql.replace('%wiki%', replacement) sql = sql.rep...
890
7c4f5e9a0a56063a7b4babd1e5144986
swh:1:cnt:c32c5c0aca7561c874ecea5733a8340c9c8732a4;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=12-44/
b61f3c0989bc3dbadc764684c941db13ce720981
kafkasse
analytics
server.js
KafkaSSEServer
type
/** * Kasse test server. * Connect to this endpoint at localhost:${port}/:topics. * Kafka broker must be running at localhost:9092. * NOTE: This is just an example server. You should * probably instantiate your own http server instnaces * and handle http requests with KafkaSSE instances in your own app. */ clas...
891
afa6c17ce8d4451351fb1dc99afeaa52
swh:1:cnt:c32c5c0aca7561c874ecea5733a8340c9c8732a4;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=22-38/
b61f3c0989bc3dbadc764684c941db13ce720981
kafkasse
analytics
server.js
KafkaSSEServer::constructor
function
constructor() { this.server = http.createServer(); this.server.on('request', (req, res) => { const splitUrl = req.url.replace('/', '').split("?timestamp="); const topics = splitUrl[0].split(','); console.log(`Handling SSE request for topics ${topics}`); co...
892
c7236f217ba53a0bac74f737203b9159
swh:1:cnt:c32c5c0aca7561c874ecea5733a8340c9c8732a4;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=40-43/
b61f3c0989bc3dbadc764684c941db13ce720981
kafkasse
analytics
server.js
KafkaSSEServer::listen
function
listen() { this.server.listen(port); console.log(`Listening for HTTP SSE connections at on port ${port}`); }
893
6aac1f5f367350889d0c18923560262b
swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=3-47/
c7c2c862631abb5881380e836f568ce1f0adbc9f
kafkasse
analytics
lib/error.js
ExtendableError
type
/** * An ExtendableError class. * This will define a non enumerable this.name property that matches * the class name during construction. * The constructor takes either an error message string, or another * Error object. If an Error object is given, the Error's enumerable * keys will be placed on this new Extena...
894
fc3f56aea8d6098b52fdcd8e5636944a
swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=108-108/
c7c2c862631abb5881380e836f568ce1f0adbc9f
kafkasse
analytics
lib/error.js
TopicNotAvailableError
type
class TopicNotAvailableError extends KafkaSSEError { }
895
47e0bdf050083bca15f416ebce45cc92
swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=107-107/
c7c2c862631abb5881380e836f568ce1f0adbc9f
kafkasse
analytics
lib/error.js
InvalidAssignmentError
type
class InvalidAssignmentError extends KafkaSSEError { }
896
3fdf370b59dde5f00b4f50bd50a06bfb
swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=106-106/
c7c2c862631abb5881380e836f568ce1f0adbc9f
kafkasse
analytics
lib/error.js
ConfigurationError
type
class ConfigurationError extends KafkaSSEError { }
897
a79c59bbfd7915a886129a71fa599db9
swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=50-103/
c7c2c862631abb5881380e836f568ce1f0adbc9f
kafkasse
analytics
lib/error.js
KafkaSSEError
type
/** * An ExtendableError class that always sets this.origin to 'KafkaSSE', * and provides a toJSON method for easy serialization. */ class KafkaSSEError extends ExtendableError { /** * Creates a new KafkaSSEError with extraPropeties * defined. * * @param {string|Error} e * @param {Object...
898
d65f1d3448cf9e88bbd4377a6cbf8629
swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=109-109/
c7c2c862631abb5881380e836f568ce1f0adbc9f
kafkasse
analytics
lib/error.js
DeserializationError
type
class DeserializationError extends KafkaSSEError { }
899
00081cd9b74b30686abcba69de93dd2b
swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=110-110/
c7c2c862631abb5881380e836f568ce1f0adbc9f
kafkasse
analytics
lib/error.js
FilterError
type
class FilterError extends KafkaSSEError { }