Dataset Viewer
Auto-converted to Parquet Duplicate
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
0
aef8c487ffeb0223cd190ce69b1274b4
swh:1:cnt:8e3d4d48f676f046f26f461e8a6dc93f873e8fe7;origin=https://gitlab.wikimedia.org/repos/data-engineering/dumps-log-analysis.git;lines=161-169/
367450d329751e05ff62643b7d16092a573e7148
dumps-log-analysis
analytics
dump_log_parser.py
check_dumps_log_path(path)
function
def check_dumps_log_path(path): # check that the log path is a file and not a directory. if not re.match(r".*\.(bz2|gz|last|zim|zip|tar|lst|7z)$", path): return False # ignore log paths that match the listed ignore regexes. for ignore_re in DUMPS_PATH_IGNORE: if re.match(ignore_re, log_p...
1
fc6c035fddd34535b81862ae26faafaa
swh:1:cnt:8e3d4d48f676f046f26f461e8a6dc93f873e8fe7;origin=https://gitlab.wikimedia.org/repos/data-engineering/dumps-log-analysis.git;lines=172-183/
367450d329751e05ff62643b7d16092a573e7148
dumps-log-analysis
analytics
dump_log_parser.py
parse_dumps_log_path(path)
function
def parse_dumps_log_path(path): for dump_name, dump_spec in DUMPS_PATH_PARSING_SPEC.items(): m = re.match(dump_spec[0], path) if m: parsed_path = {"dump_name": dump_name} for i, column in enumerate(dump_spec[1]): if column is not None: pars...
2
e89fc0fc022b9134abb0983ba04c2a2c
swh:1:cnt:65985dcafe58fac43f085fa0428f4d437c12b4ce;origin=https://gitlab.wikimedia.org/repos/data-engineering/canonical-data.git;lines=6-61/
b2c210e953ff45fe084a9bba6b3e1ed74809d3e2
canonical-data
analytics
utils.py
assert_tsv_loaded_correctly(file, table)
function
def assert_tsv_loaded_correctly(file, table): """ Checks that a loaded Data Lake table matches its source TSV file by comparing their Pandas representations. :param file: the file path of the source TSV :param table: The full name (database.table) of the loaded table :returns: None, if the...
3
2b0e3cc8ba79873899cbdc019c84f65b
swh:1:cnt:65985dcafe58fac43f085fa0428f4d437c12b4ce;origin=https://gitlab.wikimedia.org/repos/data-engineering/canonical-data.git;lines=40-48/
b2c210e953ff45fe084a9bba6b3e1ed74809d3e2
canonical-data
analytics
utils.py
assert_tsv_loaded_correctly::sort(df)
function
# Sort the data frames using the same method so that order # doesn't affect the results def sort(df): return df.sort_values( df.columns.to_list(), # We know the indexes have no information because we didn't # set one after reading ignore_index=True ...
4
ce75de0e79271a2ed4e15f9e184c23ec
swh:1:cnt:ce7a903118d82d70f5030767a7ecc289498e9a2a;origin=https://gitlab.wikimedia.org/repos/data-engineering/custom-data-monitor.git;lines=9-23/
3fcaaedf5a9a2b06218bc7284ba7317b483f217b
custom-data-monitor
analytics
main.php
schemaHasRef( array $schema, string $ref )
function
function schemaHasRef( array $schema, string $ref ): bool { $allOf = $schema['allOf'] ?? []; foreach ( $allOf as $entry ) { if ( !array_key_exists( '$ref', $entry ) ) { continue; } if ( str_starts_with( $entry['$ref'], $ref ) ) { return true; } } ...
5
feb6a8a26b604ea7e28b7a4002f36bda
swh:1:cnt:ce7a903118d82d70f5030767a7ecc289498e9a2a;origin=https://gitlab.wikimedia.org/repos/data-engineering/custom-data-monitor.git;lines=25-27/
3fcaaedf5a9a2b06218bc7284ba7317b483f217b
custom-data-monitor
analytics
main.php
schemaIsLegacyEventLogging( array $schema )
function
function schemaIsLegacyEventLogging( array $schema ): bool { return schemaHasRef( $schema, '/fragment/analytics/legacy/eventcapsule' ); }
6
a027e3d2fa41822d6c461804046b54b0
swh:1:cnt:ce7a903118d82d70f5030767a7ecc289498e9a2a;origin=https://gitlab.wikimedia.org/repos/data-engineering/custom-data-monitor.git;lines=33-45/
3fcaaedf5a9a2b06218bc7284ba7317b483f217b
custom-data-monitor
analytics
main.php
schemaGetProperties( array $schema )
function
function schemaGetProperties( array $schema ): ?array { if ( array_key_exists( 'properties', $schema ) ) { return $schema['properties']; } foreach ( $schema['allOf'] as $entry ) { if ( array_key_exists( 'properties', $entry ) ) { return $entry['properties']; } } ...
7
b7104d10eeb5fe34a9842037b047cfa5
swh:1:cnt:ce7a903118d82d70f5030767a7ecc289498e9a2a;origin=https://gitlab.wikimedia.org/repos/data-engineering/custom-data-monitor.git;lines=29-31/
3fcaaedf5a9a2b06218bc7284ba7317b483f217b
custom-data-monitor
analytics
main.php
schemaIsTestKitchen(array $schema )
function
function schemaIsTestKitchen(array $schema ): bool { return schemaHasRef( $schema, '/analytics/product_metrics' ); }
8
ddfcfed089278891703f3c8d5f5e840e
swh:1:cnt:ce7a903118d82d70f5030767a7ecc289498e9a2a;origin=https://gitlab.wikimedia.org/repos/data-engineering/custom-data-monitor.git;lines=47-65/
3fcaaedf5a9a2b06218bc7284ba7317b483f217b
custom-data-monitor
analytics
main.php
schemaGetCustomDataCount( array $schema )
function
function schemaGetCustomDataCount( array $schema ): int { $properties = schemaGetProperties( $schema ); if ( $properties === null ) { // ??? return 0; } if ( schemaIsLegacyEventLogging( $schema ) ) { $properties = schemaGetProperties( $properties['event'] ); if ( $prop...
9
e316a8b997c345b9e032ac9267aa9722
swh:1:cnt:8bcd8e4f9d731a158f6fea82079d11a3bcc5b32a;origin=https://gerrit.wikimedia.org/r/analytics/blog.git;lines=32-46/
bc8ae57c3ae04bb935516d02d9c836cd40e23619
blog
analytics
blogreport.py
parse_string_to_date(date_str)
function
def parse_string_to_date(date_str): """Parse a string into a datetime.date. If the string cannot get parsed to a date, a ValueError is raised. :param date_str: String to parse to a datetime.date """ if date_str == 'yesterday': return datetime.utcnow().date() - timedelta(days=1) # Try ...
10
524f2c1b08cb912256d2faf2a6a6679a
swh:1:cnt:8bcd8e4f9d731a158f6fea82079d11a3bcc5b32a;origin=https://gerrit.wikimedia.org/r/analytics/blog.git;lines=49-58/
bc8ae57c3ae04bb935516d02d9c836cd40e23619
blog
analytics
blogreport.py
send_email(sender, recipient, subject, text, cc=None)
function
def send_email(sender, recipient, subject, text, cc=None): """Send an e-mail by shelling out to 'sendmail'.""" message = MIMEText(text) message['From'] = sender message['To'] = recipient if cc is not None: message['Cc'] = cc message['Subject'] = subject p = subprocess.Popen(('/usr/sb...
11
edce6c80a734ad01b47e848fa7f98f0a
swh:1:cnt:8bcd8e4f9d731a158f6fea82079d11a3bcc5b32a;origin=https://gerrit.wikimedia.org/r/analytics/blog.git;lines=85-87/
bc8ae57c3ae04bb935516d02d9c836cd40e23619
blog
analytics
blogreport.py
BlogVisit
type
class BlogVisit(Base): __table__ = Table('WikimediaBlogVisit_5308166', Base.metadata, autoload=True)
12
5a3a334eb0c8c75ef6c3b329dfe08129
swh:1:cnt:bf96599fdadd3c68061aab5cbf2105bc213af91e;origin=https://gerrit.wikimedia.org/r/analytics/blog.git;lines=16-32/
3318b60b52c601a5bacd60379dc746a3f7a1ebb7
blog
analytics
tests/test_blogreport.py
UtilTestCase
type
class UtilTestCase(unittest.TestCase): def test_parse_string_to_date_yesterday(self): actual = blogreport.parse_string_to_date('yesterday') expected = (datetime.datetime.utcnow().date() - datetime.timedelta(days=1)) self.assertEqual(actual, expected) def test_parse_...
13
3ffdc75ee411e84303e3d27301635f07
swh:1:cnt:bf96599fdadd3c68061aab5cbf2105bc213af91e;origin=https://gerrit.wikimedia.org/r/analytics/blog.git;lines=17-22/
3318b60b52c601a5bacd60379dc746a3f7a1ebb7
blog
analytics
tests/test_blogreport.py
UtilTestCase::test_parse_string_to_date_yesterday(self)
function
def test_parse_string_to_date_yesterday(self): actual = blogreport.parse_string_to_date('yesterday') expected = (datetime.datetime.utcnow().date() - datetime.timedelta(days=1)) self.assertEqual(actual, expected)
14
477606039d27a8229f5a6f4029d14ac3
swh:1:cnt:bf96599fdadd3c68061aab5cbf2105bc213af91e;origin=https://gerrit.wikimedia.org/r/analytics/blog.git;lines=24-28/
3318b60b52c601a5bacd60379dc746a3f7a1ebb7
blog
analytics
tests/test_blogreport.py
UtilTestCase::test_parse_string_to_date_2014_11_08(self)
function
def test_parse_string_to_date_2014_11_08(self): actual = blogreport.parse_string_to_date('2014-11-08') expected = datetime.date(2014, 11, 8) self.assertEqual(actual, expected)
15
36fb3c71433743a8a4769188f9d1ce8e
swh:1:cnt:bf96599fdadd3c68061aab5cbf2105bc213af91e;origin=https://gerrit.wikimedia.org/r/analytics/blog.git;lines=30-32/
3318b60b52c601a5bacd60379dc746a3f7a1ebb7
blog
analytics
tests/test_blogreport.py
UtilTestCase::test_parse_string_to_date_bogus_date(self)
function
def test_parse_string_to_date_bogus_date(self): nose.tools.assert_raises(ValueError, blogreport.parse_string_to_date, 'foo')
16
967cdfce7a0c9a213746dd565c3f3563
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics-next.git;lines=17-25/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics-next
analytics
test_scripts/pyspark_test.py
python_env_info()
function
# Return the python executable and the PYTHONPATH used on a YARN PySpark worker: def python_env_info() -> dict: import os, sys, platform return { 'hostname': platform.node(), 'python': sys.executable, 'sys.path': sys.path, 'SPARK_CONF_DIR': str(os.environ.get("SPARK_CONF_DIR")) ...
17
be6eccd621218385b29984ca608cd3d1
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics-next.git;lines=70-71/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics-next
analytics
test_scripts/pyspark_test.py
pandas_subtract_mean(pdf)
function
def pandas_subtract_mean(pdf): return pdf.assign(v=pdf.v - pdf.v.mean())
18
5cddb24865738e8c56faa8b9ba1a74a8
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics-next.git;lines=45-48/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics-next
analytics
test_scripts/pyspark_test.py
do_wmf_http_requests()
function
def do_wmf_http_requests() -> List[str]: external_url = "https://en.wikipedia.org" internal_url = "https://ms-fe.svc.eqiad.wmnet/wikipedia/commons/thumb/a/a8/Tour_Eiffel_Wikimedia_Commons.jpg/100px-Tour_Eiffel_Wikimedia_Commons.jpg" return [http_request(external_url), http_request(internal_url)]
19
c430fa4c00c1178cc1a178e7cd6528d4
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics-next.git;lines=27-42/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics-next
analytics
test_scripts/pyspark_test.py
http_request(url)
function
# Test Python requests library. # Requires that CA certs are loaded properly, probably via REQUESTS_CA_BUNDLE env var. # Also requires that http_proxy, https_proxy, and no_proxy settings are correct. def http_request(url) -> dict: import requests try: return { 'url': url, 'respon...
20
967cdfce7a0c9a213746dd565c3f3563
swh:1:cnt:97d3f134a0e8adccff0d5bd21cc322fe69e4f2eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics-next.git;lines=14-22/
e4453cc4b288f3424ad40c8541243bb750ebec93
conda-analytics-next
analytics
test_scripts/spark_submit_test.py
python_env_info()
function
# Return the python executable and the PYTHONPATH used on a YARN PySpark worker: def python_env_info() -> dict: import os, sys, platform return { 'hostname': platform.node(), 'python': sys.executable, 'sys.path': sys.path, 'SPARK_CONF_DIR': str(os.environ.get("SPARK_CONF_DIR")) ...
21
42bdbcc9bd094b753e3f0d275f54b5e6
swh:1:cnt:97d3f134a0e8adccff0d5bd21cc322fe69e4f2eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics-next.git;lines=54-55/
e4453cc4b288f3424ad40c8541243bb750ebec93
conda-analytics-next
analytics
test_scripts/spark_submit_test.py
main::pandas_subtract_mean(pdf)
function
def pandas_subtract_mean(pdf): return pdf.assign(v=pdf.v - pdf.v.mean())
22
1e8938d68e1c35ad4f326338ebc32795
swh:1:cnt:97d3f134a0e8adccff0d5bd21cc322fe69e4f2eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics-next.git;lines=24-75/
e4453cc4b288f3424ad40c8541243bb750ebec93
conda-analytics-next
analytics
test_scripts/spark_submit_test.py
main()
function
def main() -> None: """ Usage: spark-submit [...] pyspark_tester.py Runs various pyspark tests to verify spark deployments in in different clusters. """ from pyspark.sql import SparkSession spark = SparkSession.builder.getOrCreate() sc = spark.sparkContext print('Driver python interpr...
23
967cdfce7a0c9a213746dd565c3f3563
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics.git;lines=17-25/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics
analytics
test_scripts/pyspark_test.py
python_env_info()
function
# Return the python executable and the PYTHONPATH used on a YARN PySpark worker: def python_env_info() -> dict: import os, sys, platform return { 'hostname': platform.node(), 'python': sys.executable, 'sys.path': sys.path, 'SPARK_CONF_DIR': str(os.environ.get("SPARK_CONF_DIR")) ...
24
c430fa4c00c1178cc1a178e7cd6528d4
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics.git;lines=27-42/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics
analytics
test_scripts/pyspark_test.py
http_request(url)
function
# Test Python requests library. # Requires that CA certs are loaded properly, probably via REQUESTS_CA_BUNDLE env var. # Also requires that http_proxy, https_proxy, and no_proxy settings are correct. def http_request(url) -> dict: import requests try: return { 'url': url, 'respon...
25
5cddb24865738e8c56faa8b9ba1a74a8
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics.git;lines=45-48/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics
analytics
test_scripts/pyspark_test.py
do_wmf_http_requests()
function
def do_wmf_http_requests() -> List[str]: external_url = "https://en.wikipedia.org" internal_url = "https://ms-fe.svc.eqiad.wmnet/wikipedia/commons/thumb/a/a8/Tour_Eiffel_Wikimedia_Commons.jpg/100px-Tour_Eiffel_Wikimedia_Commons.jpg" return [http_request(external_url), http_request(internal_url)]
26
be6eccd621218385b29984ca608cd3d1
swh:1:cnt:dc19545a75f450d1629da5e8167446fa6f7bca82;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics.git;lines=70-71/
69a24f6235d779b343b4ab6ef391d79827bd72ee
conda-analytics
analytics
test_scripts/pyspark_test.py
pandas_subtract_mean(pdf)
function
def pandas_subtract_mean(pdf): return pdf.assign(v=pdf.v - pdf.v.mean())
27
967cdfce7a0c9a213746dd565c3f3563
swh:1:cnt:97d3f134a0e8adccff0d5bd21cc322fe69e4f2eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics.git;lines=14-22/
e4453cc4b288f3424ad40c8541243bb750ebec93
conda-analytics
analytics
test_scripts/spark_submit_test.py
python_env_info()
function
# Return the python executable and the PYTHONPATH used on a YARN PySpark worker: def python_env_info() -> dict: import os, sys, platform return { 'hostname': platform.node(), 'python': sys.executable, 'sys.path': sys.path, 'SPARK_CONF_DIR': str(os.environ.get("SPARK_CONF_DIR")) ...
28
1e8938d68e1c35ad4f326338ebc32795
swh:1:cnt:97d3f134a0e8adccff0d5bd21cc322fe69e4f2eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics.git;lines=24-75/
e4453cc4b288f3424ad40c8541243bb750ebec93
conda-analytics
analytics
test_scripts/spark_submit_test.py
main()
function
def main() -> None: """ Usage: spark-submit [...] pyspark_tester.py Runs various pyspark tests to verify spark deployments in in different clusters. """ from pyspark.sql import SparkSession spark = SparkSession.builder.getOrCreate() sc = spark.sparkContext print('Driver python interpr...
29
42bdbcc9bd094b753e3f0d275f54b5e6
swh:1:cnt:97d3f134a0e8adccff0d5bd21cc322fe69e4f2eb;origin=https://gitlab.wikimedia.org/repos/data-engineering/conda-analytics.git;lines=54-55/
e4453cc4b288f3424ad40c8541243bb750ebec93
conda-analytics
analytics
test_scripts/spark_submit_test.py
main::pandas_subtract_mean(pdf)
function
def pandas_subtract_mean(pdf): return pdf.assign(v=pdf.v - pdf.v.mean())
30
7ab395d41a6a92fd88f16096217532c6
swh:1:cnt:696f27c7d9291321a76fcee37bd600fc7b2cd9ba;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=27-35/
7ba0214d2b8e625a86afcb48d5d052c6efaeed8f
blunderbuss-bugler
analytics
caller_script.py
get_bugler_env_vars()
function
def get_bugler_env_vars(): """Collect environment variables prefixed with BLUNDERBUSS_BUGLER__ and return them as a dict with the prefix stripped. """ return { key[len(ENV_VAR_PREFIX):]: value for key, value in os.environ.items() if key.startswith(ENV_VAR_PREFIX) }
31
d4d89dea61f277f88ec2389eaa36061e
swh:1:cnt:696f27c7d9291321a76fcee37bd600fc7b2cd9ba;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=46-120/
7ba0214d2b8e625a86afcb48d5d052c6efaeed8f
blunderbuss-bugler
analytics
caller_script.py
post_request(args)
function
def post_request(args): """Posts a task to Blunderbuss service using given configuration arguments, and then periodically polls for status. Returns sys.exit(0) if task successfully completed, sys.exit(1) otherwise. """ command = args.command job_label = args.job_label repo_url = args.repo_u...
32
5dcdaf101a9072c8f6545a755278af34
swh:1:cnt:696f27c7d9291321a76fcee37bd600fc7b2cd9ba;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=123-139/
7ba0214d2b8e625a86afcb48d5d052c6efaeed8f
blunderbuss-bugler
analytics
caller_script.py
run_main()
function
def run_main(): parser = argparse.ArgumentParser( description="Submit tasks to Blunderbuss", epilog="Enjoy using Blunderbuss!", usage="%(prog)s [options] command") parser.add_argument("command", choices=[Commands.CACHE_WARM_CMD, Commands.REPO_SYNC_CMD], help="Blunderbuss endpoint to cal...
33
742750ab29bade56b78627a3bddbbeb7
swh:1:cnt:696f27c7d9291321a76fcee37bd600fc7b2cd9ba;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=38-43/
7ba0214d2b8e625a86afcb48d5d052c6efaeed8f
blunderbuss-bugler
analytics
caller_script.py
Commands
type
class Commands: """Blunderbuss commands that translate to different REST endpoints. """ CACHE_WARM_CMD = "cache-warm" REPO_SYNC_CMD = "repo-sync"
34
18ff1559bd090e294e98b3170b2b2e8a
swh:1:cnt:d9508d6ca4a615f666fa75df5555c4858ef25ece;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=12-26/
4464322f222f91a3b098fc641af351d7fe189278
blunderbuss-bugler
analytics
test_caller_script.py
TestGetBuglerEnvVars
type
class TestGetBuglerEnvVars: def test_no_matching_vars(self): with mock.patch.dict(os.environ, {"PATH": "/usr/bin", "HOME": "/root"}, clear=True): assert get_bugler_env_vars() == {} def test_multiple_matching_vars(self): env = { "BLUNDERBUSS_BUGLER__TOKEN": "secret", ...
35
3bae57ee6256894cb26418039039d797
swh:1:cnt:d9508d6ca4a615f666fa75df5555c4858ef25ece;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=29-65/
4464322f222f91a3b098fc641af351d7fe189278
blunderbuss-bugler
analytics
test_caller_script.py
TestPostRequestPayload
type
class TestPostRequestPayload: """Verify that blunderbuss_bugler_env_vars is included for cache-warm.""" BASE_ARGS = { "job_label": "test-job", "repo_url": "https://example.com/repo", "branch": "main", "instances": "main,search", "bb_host": "https://blunderbuss.example.co...
36
a7b7ad0d1aae708c8118368aeb2d392a
swh:1:cnt:d9508d6ca4a615f666fa75df5555c4858ef25ece;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=13-15/
4464322f222f91a3b098fc641af351d7fe189278
blunderbuss-bugler
analytics
test_caller_script.py
TestGetBuglerEnvVars::test_no_matching_vars(self)
function
def test_no_matching_vars(self): with mock.patch.dict(os.environ, {"PATH": "/usr/bin", "HOME": "/root"}, clear=True): assert get_bugler_env_vars() == {}
37
14b57378505e8b62f73db6fe7c663ac8
swh:1:cnt:d9508d6ca4a615f666fa75df5555c4858ef25ece;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=46-65/
4464322f222f91a3b098fc641af351d7fe189278
blunderbuss-bugler
analytics
test_caller_script.py
TestPostRequestPayload::test_cache_warm_includes_env_vars(self, mock_post)
function
def test_cache_warm_includes_env_vars(self, mock_post): mock_response = mock.Mock() mock_response.json.return_value = {"task_id": "task-1"} mock_response.raise_for_status = mock.Mock() mock_post.return_value = mock_response # Mock the polling GET to return a completed task immed...
38
c929268dccb0bb839a7873e450a521ac
swh:1:cnt:d9508d6ca4a615f666fa75df5555c4858ef25ece;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=41-42/
4464322f222f91a3b098fc641af351d7fe189278
blunderbuss-bugler
analytics
test_caller_script.py
TestPostRequestPayload::_make_args(self, command)
function
def _make_args(self, command): return argparse.Namespace(command=command, **self.BASE_ARGS)
39
8a7d895ce087546561c13280e360359d
swh:1:cnt:d9508d6ca4a615f666fa75df5555c4858ef25ece;origin=https://gitlab.wikimedia.org/repos/data-engineering/blunderbuss-bugler.git;lines=17-26/
4464322f222f91a3b098fc641af351d7fe189278
blunderbuss-bugler
analytics
test_caller_script.py
TestGetBuglerEnvVars::test_multiple_matching_vars(self)
function
def test_multiple_matching_vars(self): env = { "BLUNDERBUSS_BUGLER__TOKEN": "secret", "BLUNDERBUSS_BUGLER__OTHER": "value", "OTHER_VAR": "no", "BLUNDERBUSS_BUGLER_SINGLE_UNDERSCORE": "no", "BLUNDERBUSS_BUGLER__KEY": "" } with mock.patch...
40
091d7483677b46fb351796c7332628f3
swh:1:cnt:70f36698405aa10d7613dd3ccd05a9a9c163e81f;origin=https://gitlab.wikimedia.org/repos/data-engineering/example-job-project.git;lines=2-7/
5094e702b7f0fab8b84260aef576d050c5c66e82
example-job-project
analytics
example_job_project/util.py
sum_ints(a: int, b: int)
function
def sum_ints(a: int, b: int) -> int: """ :return: a + b """ return a + b
41
3be25eb88f67e7e7b1ac5c887dc23cee
swh:1:cnt:70f36698405aa10d7613dd3ccd05a9a9c163e81f;origin=https://gitlab.wikimedia.org/repos/data-engineering/example-job-project.git;lines=9-21/
5094e702b7f0fab8b84260aef576d050c5c66e82
example-job-project
analytics
example_job_project/util.py
prefix_str(prefix: str, target: str)
function
def prefix_str(prefix: str, target: str): """ :param prefix: The prefix string :param target: The target string :return: target string prefixed with prefix string """ return prefix + target
42
5901c052384f7546efdb283c9bfcd69a
swh:1:cnt:a62d97c52b2eab5bfbe7faef9020d19c14894c58;origin=https://gitlab.wikimedia.org/repos/data-engineering/example-job-project.git;lines=3-4/
234013afe2ea882d4c6bc0072f8e2b8b4abec4b2
example-job-project
analytics
tests/test_util.py
test_sum_ints()
function
def test_sum_ints(): assert sum_ints(1, 2) == 3
43
816db90eb8e7c6a6e60070b9af0dda38
swh:1:cnt:a62d97c52b2eab5bfbe7faef9020d19c14894c58;origin=https://gitlab.wikimedia.org/repos/data-engineering/example-job-project.git;lines=6-8/
234013afe2ea882d4c6bc0072f8e2b8b4abec4b2
example-job-project
analytics
tests/test_util.py
test_prefix_str()
function
def test_prefix_str(): assert prefix_str('my_', 'target') == 'my_target' assert prefix_str('your_', 'target') == 'your_target'
44
111dd80f6341b3cec7eb93d807e05558
swh:1:cnt:12b29d95e7f445a916415daab98a54da5994f5b4;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=4-4/
1c0232d7b8e392b0fe8b3d0268b19fd9f6cda1dd
dataset-config-store-service
analytics
utils/ConfigStore.ts
ConfigStoreBackend
type
type ConfigStoreBackend = "api" | "repo";
45
8878c9fd80849ccab15e58a1572cade6
swh:1:cnt:12b29d95e7f445a916415daab98a54da5994f5b4;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=10-20/
1c0232d7b8e392b0fe8b3d0268b19fd9f6cda1dd
dataset-config-store-service
analytics
utils/ConfigStore.ts
ConfigSchemaProperties
type
type ConfigSchemaProperties = { properties: { [key: string]: { type?: string; const?: any; default?: any; properties?: { [key: string]: { type: string } }; items?: { type: string }; }; }; };
46
dd4af97cd8b1850a75cba0535e56ba3a
swh:1:cnt:12b29d95e7f445a916415daab98a54da5994f5b4;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=6-8/
1c0232d7b8e392b0fe8b3d0268b19fd9f6cda1dd
dataset-config-store-service
analytics
utils/ConfigStore.ts
ConfigOptions
type
interface ConfigOptions { gitSHA?: string; }
47
4e4e35940e51bfbe6e9c92df416beed4
swh:1:cnt:12b29d95e7f445a916415daab98a54da5994f5b4;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=25-28/
1c0232d7b8e392b0fe8b3d0268b19fd9f6cda1dd
dataset-config-store-service
analytics
utils/ConfigStore.ts
constructor
function
constructor(storage?: Storage<StorageValue>, logger?: winston.Logger) { this.storage = storage ?? useStorage("configStore"); this.logger = logger; }
48
df91c21a53d1a0c1c8adb7cb616c471b
swh:1:cnt:12b29d95e7f445a916415daab98a54da5994f5b4;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=35-75/
1c0232d7b8e392b0fe8b3d0268b19fd9f6cda1dd
dataset-config-store-service
analytics
utils/ConfigStore.ts
normalizeConfig
function
/** * Sets defaults and consts specified in the configSchema to the config. * * @param configSchema * @param config * @returns */ static normalizeConfig( configSchema: ConfigSchemaProperties, config: object ): object { let normalizedConfig: { [key: string]: any } = {}; for (const ...
49
1c064a14c737e67f45644a781fe7f07b
swh:1:cnt:16546bd6be152eb0554d56a3a3463dc9c9210b0b;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=37-78/
e6b1edade906b8db5b75b68318823bcc694dadd7
dataset-config-store-service
analytics
utils/GitLabAPIConfigStore.ts
GitLabAPIConfigStore
type
class GitLabAPIConfigStore extends ConfigStore { public gitLabProjectPath: string; constructor( storage?: Storage<StorageValue>, logger?: winston.Logger, gitLabProjectPath?: string ) { super(storage); this.gitLabProjectPath = gitLabProjectPath ?? useRuntimeConfig().configStore.configRepo...
50
4fe478b57bf105204416115f2dc806e2
swh:1:cnt:16546bd6be152eb0554d56a3a3463dc9c9210b0b;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=39-57/
e6b1edade906b8db5b75b68318823bcc694dadd7
dataset-config-store-service
analytics
utils/GitLabAPIConfigStore.ts
GitLabAPIConfigStore::constructor
function
constructor( storage?: Storage<StorageValue>, logger?: winston.Logger, gitLabProjectPath?: string ) { super(storage); this.gitLabProjectPath = gitLabProjectPath ?? useRuntimeConfig().configStore.configRepoProjectPath; if (!this.gitLabProjectPath) { logger.error( "A git repo...
51
ed6d34b09a5a779acb4fcea0bdc11b61
swh:1:cnt:16546bd6be152eb0554d56a3a3463dc9c9210b0b;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=59-77/
e6b1edade906b8db5b75b68318823bcc694dadd7
dataset-config-store-service
analytics
utils/GitLabAPIConfigStore.ts
GitLabAPIConfigStore::getNormalizedConfig
function
async getNormalizedConfig( path: string, options?: ConfigOptions ): Promise<object> { const configYaml = await fetchConfigValues(path, options.gitSHA); const config = parse(configYaml); const schemaPath = config.$schema; if (!schemaPath) { throw new Error("Schema not found"); } c...
52
fe0f0f68a6201c5971f6c984361ff2a0
swh:1:cnt:a6e5d7b162349da426a474e46e4eb5bd5279b510;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=32-102/
af767f2d4d6d809a1179caccb01ebb778c78f02e
dataset-config-store-service
analytics
utils/GitRepoConfigStore.ts
GitRepoConfigStore
type
class GitRepoConfigStore extends ConfigStore { public gitDirectory: string; public configDevMode: boolean; constructor( storage?: Storage<StorageValue>, logger?: winston.Logger, gitParentDirectory?: string, configDevMode?: boolean ) { super(storage); this.gitDirectory = path.resolve( ...
53
c32901f702a38c553dafdcd0f9c26949
swh:1:cnt:a6e5d7b162349da426a474e46e4eb5bd5279b510;origin=https://gitlab.wikimedia.org/repos/data-engineering/dataset-config-store-service.git;lines=35-52/
af767f2d4d6d809a1179caccb01ebb778c78f02e
dataset-config-store-service
analytics
utils/GitRepoConfigStore.ts
GitRepoConfigStore::constructor
function
constructor( storage?: Storage<StorageValue>, logger?: winston.Logger, gitParentDirectory?: string, configDevMode?: boolean ) { super(storage); this.gitDirectory = path.resolve( gitParentDirectory ? gitParentDirectory : process.env.PWD, "config" ); this.configDevMode = conf...
54
f318aa3aa685c26bcb3137ab7788a52e
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=42-45/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
check_devenv_exists(name)
function
def check_devenv_exists(name): if name not in list_devenvs(short=True): click.echo(f"No such airflow development environment {name}") sys.exit(1)
55
657799a6b54860be3f6a208497dcfcf1
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=88-101/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
DagsFolders::convert(self, value, param, ctx)
function
def convert(self, value, param, ctx) -> str: try: return super(DagsFolders, self).convert(value, param, ctx) except click.BadParameter as e: if gitlabmanager.branch != gitlabmanager.project.default_branch: log.warning( "DAGs folder %s wasn't fo...
56
366abffea4667b650f58e515d30be9be
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=51-55/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
GitBranch::convert(self, value, param, ctx)
function
def convert(self, value, param, ctx) -> str: if not gitlabmanager.get_branch(value): self.fail(f"Branch {value} does not exist.", param, ctx) gitlabmanager.branch = value return value
57
89aa4758b568fa290d50d2f7f8b4e856
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=61-77/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
ChangesOnly::convert(self, value, param, ctx)
function
def convert(self, value, param, ctx) -> None: if value == True: if not ctx.default_map: ctx.default_map = dict() try: dags_folder, dags_files = gitlabmanager.resolve_dags( dags_folder=ctx.params.get("dags_folder") ) ...
58
99e24c56a6b925c69a829467ec979654
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=83-86/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
DagsFolders::__init__(self)
function
def __init__(self) -> None: return super(DagsFolders, self).__init__( gitlabmanager.list_dags_folders(), case_sensitive=True )
59
0dd5fced9e3d0d3deb578e9486294017
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=107-111/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
DagsFiles::convert(self, value, param, ctx)
function
def convert(self, value, param, ctx) -> list[str]: if isinstance(value, list): return value # missing actual validation return value.split(",")
60
13d925edac41b1fb246d63057a4d1a51
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=117-118/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
cli()
function
def cli(): """Manage ephemeral Airflow development environments"""
61
5fe3f97aad32a3505d2b49acbe7131ae
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=179-280/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
create( branch: str, name: str, dags_folder: str, charts_folder: str, dags_files: list[str] = [], set_csv: Optional[str] = None, )
function
def create( branch: str, name: str, dags_folder: str, charts_folder: str, dags_files: list[str] = [], set_csv: Optional[str] = None, ): """Provision an ephemeral airflow development environment""" kubernetes.config.load_kube_config(KUBECONFIG_FILE) core_v1 = core_v1_api.CoreV1Api() ...
62
a23c8f2641698d82195b391b1c926e91
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=285-290/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
expose(devenv_name: str)
function
def expose(devenv_name: str): """Expose the airflow webserver UI to your local workstation""" check_devenv_exists(devenv_name) kubernetes.config.load_kube_config(KUBECONFIG_FILE) core_v1 = core_v1_api.CoreV1Api() port_forward_to_webserver(devenv_name=devenv_name, core_v1=core_v1)
63
16cd27597f50460317ae3db5bbaba36f
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=298-314/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
destroy(devenv_name: str)
function
def destroy(devenv_name: str): """Destroy the argument airflow development environment""" check_devenv_exists(devenv_name) db_name = devenv_name.replace("-", "_") # dashes are not supported in PG DB names s3_client = create_s3_client() with progress_message(f"Uninstalling airflow dev environment {...
64
6ad5ab257ccfd75341452dcf09f6e89a
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=326-329/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
show(devenv_name: str, watch: bool = False)
function
def show(devenv_name: str, watch: bool = False): """Show all pods of the argument airflow development environment""" check_devenv_exists(devenv_name) show_devenv_pods(devenv_name=devenv_name, watch=watch)
65
4b743e963600f49f69645f0d4c27f3ef
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=333-335/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
list_cmd()
function
def list_cmd(): """List Airflow development environments""" click.echo("\n".join(list_devenvs()))
66
e8c1d1b3646a2fdc7f3f8bfea726fbac
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=342-348/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
exec(pod_name: str, cmd: str, container_name: Optional[str] = None)
function
def exec(pod_name: str, cmd: str, container_name: Optional[str] = None): """Execute a command in one of the airflow development environment pods""" pod_exec( pod_name=pod_name, container_name=container_name, command=cmd, )
67
844edf74dd00d68c8c2d3a47e93ac86c
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=403-415/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
reauth(devenv_name: str)
function
def reauth(devenv_name: str): """Re-obtain a new Kerberos ticket""" check_devenv_exists(devenv_name) kubernetes.config.load_kube_config(KUBECONFIG_FILE) core_v1 = core_v1_api.CoreV1Api() kerberos_pod_name = wait_for_pod( component="kerberos", devenv_name=devenv_name, core_v1=core_v1 ) ...
68
9fdfed3b8d4ca528747544c444415916
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=418-420/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
runcli()
function
def runcli(): """Entry point for production utility""" cli(max_content_width=120)
69
f464271bd4d96d6842f2b9f9914513e1
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=368-387/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
logs( devenv_name: str, component: str, container_name: str, tail: int = -1, follow: bool = False, )
function
def logs( devenv_name: str, component: str, container_name: str, tail: int = -1, follow: bool = False, ): """Tail logs for a given pod in your airflow development environment""" check_devenv_exists(devenv_name) if container_name is None: container_name = f"airflow-{devenv_name}" ...
70
16a3baf4bc764965823561321cf7ebd7
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=392-397/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
yaml( devenv_name: str, )
function
def yaml( devenv_name: str, ): """Display all rendered yaml Kubernetes manifests for a development environment""" check_devenv_exists(devenv_name) helm_get_devenv_manifests(devenv_name)
71
3d1f0b06295a53441a406304900531d8
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=48-55/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
GitBranch
type
class GitBranch(click.ParamType): name = "branch-name" def convert(self, value, param, ctx) -> str: if not gitlabmanager.get_branch(value): self.fail(f"Branch {value} does not exist.", param, ctx) gitlabmanager.branch = value return value
72
7ae575bdaf0694e10550f8de479e5642
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=80-101/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
DagsFolders
type
class DagsFolders(click.Choice): name = "dags-folder" def __init__(self) -> None: return super(DagsFolders, self).__init__( gitlabmanager.list_dags_folders(), case_sensitive=True ) def convert(self, value, param, ctx) -> str: try: return super(DagsFolders, s...
73
173035d4fbb1d8809adef187756415c5
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=104-111/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
DagsFiles
type
class DagsFiles(click.ParamType): name = "dags-files" def convert(self, value, param, ctx) -> list[str]: if isinstance(value, list): return value # missing actual validation return value.split(",")
74
5e202d33e72dac797a0a18a616766f13
swh:1:cnt:033f9c92090dfa7e60f1c1b2b3686770d8ff4e94;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=58-77/
2494398c7026b5ba31e0a8e5752258ce26ea71d1
airflow-devenv
analytics
airflow_devenv/cli.py
ChangesOnly
type
class ChangesOnly(click.ParamType): name = "changes-only" def convert(self, value, param, ctx) -> None: if value == True: if not ctx.default_map: ctx.default_map = dict() try: dags_folder, dags_files = gitlabmanager.resolve_dags( ...
75
8e26d8aea27973890656c8a8b11fe694
swh:1:cnt:a3717d3ad5dd45f29c84b320b66ec9ab60f64ab4;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=15-113/
d0ebc98ababea9fb7338c5371a62393008e60d3c
airflow-devenv
analytics
airflow_devenv/gitlab.py
GitLabManager
type
class GitLabManager: def __init__(self) -> None: gl = gitlab.Gitlab("https://gitlab.wikimedia.org") self.project = gl.projects.get("repos/data-engineering/airflow-dags") self.branch = default_devenv_name() if not self.get_branch(self.branch): log.warning( ...
76
e04c2b2ebbd4ddb0c1bce7c47d7bd768
swh:1:cnt:a3717d3ad5dd45f29c84b320b66ec9ab60f64ab4;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=17-27/
d0ebc98ababea9fb7338c5371a62393008e60d3c
airflow-devenv
analytics
airflow_devenv/gitlab.py
GitLabManager::__init__(self)
function
def __init__(self) -> None: gl = gitlab.Gitlab("https://gitlab.wikimedia.org") self.project = gl.projects.get("repos/data-engineering/airflow-dags") self.branch = default_devenv_name() if not self.get_branch(self.branch): log.warning( "branch %s does not exist...
77
c570b58ebb6130ecf598e76bb1efabd5
swh:1:cnt:a3717d3ad5dd45f29c84b320b66ec9ab60f64ab4;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=40-44/
d0ebc98ababea9fb7338c5371a62393008e60d3c
airflow-devenv
analytics
airflow_devenv/gitlab.py
GitLabManager::_list_dags_folders::_is_dag_folder(folder_name: str)
function
def _is_dag_folder(folder_name: str) -> tuple[str, bool]: for subfolder in self.project.repository_tree(folder_name, ref=branch): if subfolder["type"] == "tree" and subfolder["name"] == "dags": return folder_name, True return folder_name, False
78
3a9d92b3219ee0e7fe1310befe5b8851
swh:1:cnt:a3717d3ad5dd45f29c84b320b66ec9ab60f64ab4;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=33-67/
d0ebc98ababea9fb7338c5371a62393008e60d3c
airflow-devenv
analytics
airflow_devenv/gitlab.py
GitLabManager::_list_dags_folders(self, branch: str)
function
def _list_dags_folders(self, branch: str) -> list[str]: """Return a list of dags folder in the airflow-dags repo. A dags folder is any root-level folder that contains a `dags` subfolder. """ def _is_dag_folder(folder_name: str) -> tuple[str, bool]: for subfolder in self.pr...
79
17ad0402893f6d01c82993fdf3f82848
swh:1:cnt:a3717d3ad5dd45f29c84b320b66ec9ab60f64ab4;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=70-75/
d0ebc98ababea9fb7338c5371a62393008e60d3c
airflow-devenv
analytics
airflow_devenv/gitlab.py
GitLabManager::get_branch(self, branch_name: str)
function
def get_branch(self, branch_name: str): """Return whether a given branch name exists in the airlfow-dags project""" try: return self.project.branches.get(branch_name) except gitlab.exceptions.GitlabGetError: return None
80
45587530d7757da123818ee7d11cd548
swh:1:cnt:a3717d3ad5dd45f29c84b320b66ec9ab60f64ab4;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=29-30/
d0ebc98ababea9fb7338c5371a62393008e60d3c
airflow-devenv
analytics
airflow_devenv/gitlab.py
GitLabManager::list_dags_folders(self)
function
def list_dags_folders(self) -> list[str]: return self._list_dags_folders(self.branch)
81
b8ea6de5588ba5093eec04ec9d5ec2ad
swh:1:cnt:a3717d3ad5dd45f29c84b320b66ec9ab60f64ab4;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=77-113/
d0ebc98ababea9fb7338c5371a62393008e60d3c
airflow-devenv
analytics
airflow_devenv/gitlab.py
GitLabManager::resolve_dags(self, dags_folder: Optional[str])
function
def resolve_dags(self, dags_folder: Optional[str]) -> tuple[str, list[str]]: main = self.get_branch(self.project.default_branch) target = self.get_branch(self.branch) if not main and not target: raise ValueError("no branch data") main_id: str = main.commit["id"] # type: igno...
82
0102f70515f801e2fb3a0d51a1c8247e
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=97-100/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
run_command_on_pg_master(cmd: str)
function
def run_command_on_pg_master(cmd: str): pg_master_pod_name = find_pg_master_pod() cmd_list = ["kubectl", "exec", "-it", pg_master_pod_name, "--"] + cmd.split() return run_kubernetes_command(cmd_list, capture_output=True, check=True)
83
fcb29501379e9caad3702529a7558ee3
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=192-198/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
helm_uninstall_airflow_dev(release_name: str)
function
def helm_uninstall_airflow_dev(release_name: str): cmd = [ "helm", "uninstall", release_name, ] run_kubernetes_command(cmd, capture_output=True)
84
98f0fe518f07bea12013ed41bebb05a9
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=103-110/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
create_db(db_name: str)
function
def create_db(db_name: str): try: run_command_on_pg_master(cmd=f"createdb {db_name} --owner app") except subprocess.CalledProcessError as exc: if "already exists" in exc.output.decode("utf-8"): pass else: raise exc
85
c65363538c9b2d4e31444eaa3595821f
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=201-227/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
wait_for_kerberos_pod_init_container( devenv_name: str, core_v1: core_v1_api.CoreV1Api, )
function
def wait_for_kerberos_pod_init_container( devenv_name: str, core_v1: core_v1_api.CoreV1Api, ) -> Tuple[str, str]: print("- Waiting for the kerberos pod to start ", end="", flush=True) while not ( kerberos_pods := core_v1.list_namespaced_pod( namespace=NAMESPACE, label_sel...
86
107794820a1a21f000c37e41ed5d6e1c
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=49-53/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
get_airflow_instance_private_values(instance_name: str)
function
def get_airflow_instance_private_values(instance_name: str) -> dict: airflow_release_values_file = ( f"{PRIVATE_CONFIG_FILE_PARENT_DIR}/{instance_name}/{ENVIRONMENT}.yaml" ) return yaml.safe_load(open(airflow_release_values_file))
87
67b94b94b86c51c78abde3db34d6e2b8
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=79-86/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
run_kubernetes_command( cmd: list[str], capture_output: bool = False, check: bool = False )
function
def run_kubernetes_command( cmd: list[str], capture_output: bool = False, check: bool = False ) -> subprocess.CompletedProcess[bytes]: if debug(): click.secho("\n" + " ".join(display_debug_cmd(cmd)), fg="blue") return subprocess.run( cmd, env=KUBECTL_ENV, capture_output=capture_output, check...
88
907a1da45241d774af1e3716fa03183d
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=230-252/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
wait_for_pod( component: str, devenv_name: str, core_v1: core_v1_api.CoreV1Api )
function
def wait_for_pod( component: str, devenv_name: str, core_v1: core_v1_api.CoreV1Api ) -> str: print(f"- Waiting for the {component} pod to be ready ", end="", flush=True) while not ( pods := core_v1.list_namespaced_pod( namespace=NAMESPACE, label_selector=f"release={devenv_nam...
89
bb921b19d441142defbe02c45b051137
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=279-290/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
force_dag_serialization(scheduler_pod_name: str)
function
def force_dag_serialization(scheduler_pod_name: str): cmd = [ "kubectl", "exec", "-it", scheduler_pod_name, "--", "airflow", "dags", "reserialize", ] run_kubernetes_command(cmd, capture_output=True)
90
8d781a2dda8a2397d998a0347cc71353
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=56-76/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
display_debug_cmd(cmd: list[str])
function
def display_debug_cmd(cmd: list[str]): """Return the input command list with values of --set-json arguments marked as REDACTED""" debug_cmd = cmd[:] next_is_json_secret = False for i, token in enumerate(cmd): if token == "--set-json": next_is_json_secret = True elif next_is_j...
91
1a48a70165f24fddd62cd4d159ba35e0
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=89-94/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
find_pg_master_pod()
function
def find_pg_master_pod() -> str: cmd = ["kubectl", "get", "cluster", "postgresql-airflow-dev", "-o", "json"] completed_process = run_kubernetes_command(cmd, capture_output=True) stdout = completed_process.stdout.decode("utf-8") cluster_json = json.loads(stdout) return cluster_json["status"]["current...
92
658c87f27f5a5b696962c0193551d645
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=255-276/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
prompt_user_for_kinit_password( username: str, kerberos_pod_name: str, kinit_container_name: str )
function
def prompt_user_for_kinit_password( username: str, kerberos_pod_name: str, kinit_container_name: str ): # I've tried to do this using the kubernetes python client. Believe me, it's just # simpler this way. cmd = [ "kubectl", "exec", "-it", kerberos_pod_name, "-c",...
93
c341a1bf4f05dd79821a96d66b22d9d7
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=293-321/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
create_airflow_admin_user( devenv_name: str, webserver_pod_name: str, username: str, password: str, )
function
def create_airflow_admin_user( devenv_name: str, webserver_pod_name: str, username: str, password: str, ): cmd = [ "kubectl", "exec", "-it", webserver_pod_name, "--", "airflow", "users", "create", "--email", f"admin@airf...
94
5b574935109666c8f091fb242f650bec
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=113-120/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
drop_db(db_name: str)
function
def drop_db(db_name: str): try: run_command_on_pg_master(cmd=f"dropdb {db_name} --force") except subprocess.CalledProcessError as exc: if "does not exist" in exc.output.decode("utf-8"): pass else: raise exc
95
e2fe6bc6950e4e8a8e4fbf2fd3e16344
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=342-351/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
is_port_free(port: int)
function
def is_port_free(port: int) -> bool: """Return whether the argument port is free""" sock = socket.socket() with contextlib.closing(sock): try: sock.bind(("", port)) except OSError: return False else: return True
96
47d7205ccf5ed4cfe00161205b2b28fd
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=369-397/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
port_forward_to_webserver(devenv_name: str, core_v1: core_v1_api.CoreV1Api)
function
def port_forward_to_webserver(devenv_name: str, core_v1: core_v1_api.CoreV1Api): free_port = get_devenv_expose_tcp_port(devenv_name) print("On your workstation, run the following command:") print(f"ssh -N deployment.eqiad.wmnet -L 127.0.0.1:8080:127.0.0.1:{free_port}") print("then open http://localhost:...
97
61485154131b20062a1d3fa52ab2a817
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=45-46/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
debug()
function
def debug() -> bool: return log.level == logging.DEBUG
98
62cfa06d9e3450c6ac11ce38de49f477
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=123-189/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
helm_install_airflow_dev( release_name: str, environment: str, db_name: str, git_ref: str, dags_folder: str, principal: str, charts_dir: str, set_values: list[str], extra_json_values: Optional[dict], )
function
def helm_install_airflow_dev( release_name: str, environment: str, db_name: str, git_ref: str, dags_folder: str, principal: str, charts_dir: str, set_values: list[str], extra_json_values: Optional[dict], ): instance_name = f"airflow-{dags_folder.replace('_', '-')}" cmd = [ ...
99
ee86bc85b52b223934d4200a05e6a9bb
swh:1:cnt:4dfd0b54d7b1b08657934452d5607b250ccc6880;origin=https://gitlab.wikimedia.org/repos/data-engineering/airflow-devenv.git;lines=354-366/
9ac3b1d70e2d38cc79c1f1d11bdc1cec34cbb818
airflow-devenv
analytics
airflow_devenv/k8s.py
get_devenv_expose_tcp_port(devenv_name: str)
function
def get_devenv_expose_tcp_port(devenv_name: str): """Returnn a TCP port used to expose the devenv webserver pod Either bind to the stable devenv expose port, or find a free port. note that this process is inherently racy, but should work most of the time just fine. """ devenv_expose_port = dev...
End of preview. Expand in Data Studio

MediaWiki Code2Code Search — Dataset

Pre-computed retrieval artifacts for MediaWiki Code2Code Search, a neural system for the semantic discovery of open-source software entities (functions, types, templates) across the MediaWiki / Wikimedia ecosystem.

This Hugging Face dataset is a complementary mirror of the pre-computed artifacts archived on Zenodo (10.5281/zenodo.20586256). The Hugging Face copy makes the corpus browsable in the dataset Viewer and easy to pull with the datasets / huggingface_hub libraries.

If you use this dataset, please cite the paper (see Citation). Zenodo is the archival home of the artifacts; the paper is the reference to cite.

  • Code / system: https://github.com/ftosoni/mediawiki-code2code-search
  • Paper: MediaWiki Code2Code Search: Neural Retrieval for the Semantic Discovery of Open-Source Software Entities — Francesco Tosoni, Sant'Anna School of Advanced Studies, Pisa. A peer-reviewed version is forthcoming in SoftwareX. See Citation.

Contents

File Size Format Description
data/train-*.parquet (9 shards) ~172 MiB Parquet (zstd) The full snippets table, exposed for the dataset Viewer and load_dataset. Same 1,289,452 rows as snippets.db.
snippets.db 1.74 GiB SQLite Serving metadata + code for every entity (single snippets table).
embeddings.npy 4.92 GiB NumPy float32 Dense embeddings, shape (1289452, 1024), L2-normalised, from Qwen/Qwen3-Embedding-0.6B. Row i aligns with snippets.db row id = i.
mediawiki.index 168.6 MiB FAISS IndexIVFPQ (L2) with an IndexFlatL2 coarse quantizer, 128 sub-quantizers × 8 bits, dim 1024. Built over the embeddings above.
bm25_index.pkl 423.6 MiB Pickle BM25 lexical baseline built over the code field (identifier tokeniser; keywords and tokens shorter than three characters dropped).

Note on .npy / .index / .pkl: these binary artifacts do not render in the Viewer by design; the Parquet shards provide the browsable view of the same underlying rows.

Also on Zenodo only: the raw pre-migration corpus raw_snippets.json (~1.75 GiB) lives in the Zenodo record but is intentionally not mirrored here — its content is already captured by snippets.db and the Parquet shards.

Data fields (snippets table / Parquet)

Column Type Description
id int64 Row id; aligns with the corresponding row of embeddings.npy.
original_id string Upstream extraction id (content hash).
swhid string SWHID of the source content, with origin= and lines= qualifiers — resolvable on Software Heritage for exact provenance and upstream licensing.
sha1 string SHA-1 of the source blob.
repo_name string Upstream repository name.
repo_group string Repository group / namespace.
filepath string Path of the source file within the repository.
name string Entity name / signature (e.g. check_dumps_log_path(path)).
type string One of function, type, template.
code string Source snippet text for the entity (see Licensing).

Corpus statistics

  • 1,289,452 structural entities:
    • function: 1,050,748
    • type: 237,653
    • template: 1,051
  • 2,242 active repositories (distinct (repo_group, repo_name) pairs) across the MediaWiki / Wikimedia ecosystem.
  • 12 programming languages extracted via language-specific structural parsing.
  • Embedding model: Qwen/Qwen3-Embedding-0.6B (1024-dim). Retrieval is nearest-neighbour by Euclidean (L2) distance over L2-normalised vectors.

Usage

Browse the corpus in the Viewer above, or load it programmatically.

Tabular rows (Parquet) with datasets:

from datasets import load_dataset

ds = load_dataset("ftosoni/mediawiki-code2code-search", split="train")
print(ds)
print(ds[0]["name"], ds[0]["type"])
print(ds[0]["swhid"])

Raw serving artifacts with huggingface_hub:

from huggingface_hub import hf_hub_download

repo = "ftosoni/mediawiki-code2code-search"
db    = hf_hub_download(repo, "snippets.db",      repo_type="dataset")
emb   = hf_hub_download(repo, "embeddings.npy",   repo_type="dataset")
index = hf_hub_download(repo, "mediawiki.index",  repo_type="dataset")
bm25  = hf_hub_download(repo, "bm25_index.pkl",   repo_type="dataset")

import numpy as np, faiss
X = np.load(emb, mmap_mode="r")        # (1289452, 1024) float32, L2-normalised
faiss_index = faiss.read_index(index)  # IndexIVFPQ (L2)

embeddings.npy row i corresponds to snippets.db row id = i and to FAISS vector i.


Licensing (important)

This dataset combines two distinct layers, and they carry different licenses:

  1. Tooling / packaging (schema, indexes, embeddings, this card): Apache-2.0, matching the canonical Zenodo record.
  2. The code snippets in snippets.db / the Parquet shards are derived from upstream MediaWiki / Wikimedia repositories, each under its own free/open-source license (predominantly GPL-2.0-or-later, with some MIT / BSD / Apache-2.0 and others). These upstream licenses govern the snippet text; redistribution here relies on their permission to redistribute.

There is no per-row license column. Instead, every entity carries an swhid with an origin= qualifier, so the exact upstream repository — and therefore its authoritative license and copyright — can be resolved on Software Heritage and at the origin repository. Snippets are fragments and may not carry their file's original license header; consult the origin before reuse.

See LICENSE.md for the full statement.


Citation

Please cite the paper:

@misc{tosoni2026mediawikicode2codesearchneural,
  title         = {MediaWiki Code2Code Search: Neural Retrieval for the Semantic Discovery of Open-Source Software Entities},
  author        = {Francesco Tosoni},
  year          = {2026},
  eprint        = {2607.26766},
  archivePrefix = {arXiv},
  primaryClass  = {cs.IR},
  url           = {https://arxiv.org/abs/2607.26766}
}

The pre-computed artifacts are archived on Zenodo: 10.5281/zenodo.20586256. A peer-reviewed version of the paper is forthcoming in SoftwareX.


Acknowledgements

Corpus derived from the MediaWiki / Wikimedia software ecosystem. Provenance is tracked with SWHID identifiers resolvable on Software Heritage. Embeddings computed with Qwen/Qwen3-Embedding-0.6B; indexing with FAISS.

Downloads last month
-

Paper for ftosoni/mediawiki-code2code-search