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 |
|---|---|---|---|---|---|---|---|---|---|
4,400 | 2bf3905a975216905d1f4cb90ea84b66 | swh:1:cnt:df80d583eed3ba763d5d569f28fceb656397c598;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=161-188/ | 99deec58e0c1ebd4f9564c7e2cffbe5b00ec9623 | workflow_utils | analytics | workflow_utils/conda.py | conda_cli(
args: Optional[List[str]] = None,
conda_exe: Optional[str] = None,
) | function | def conda_cli(
args: Optional[List[str]] = None,
conda_exe: Optional[str] = None,
) -> int:
"""
Shells out to conda_exe to run a command.
:param args:
args to pass to the conda executable.
:conda_exe:
Path to conda executable. If not given, one will
be found via find_co... |
4,401 | b8ae1838a66388621855e094e9da13b0 | swh:1:cnt:df80d583eed3ba763d5d569f28fceb656397c598;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=222-245/ | 99deec58e0c1ebd4f9564c7e2cffbe5b00ec9623 | workflow_utils | analytics | workflow_utils/conda.py | conda_env_update(
prefix: str,
args: Optional[List[str]] = None,
conda_exe: Optional[str] = None,
) | function | def conda_env_update(
prefix: str,
args: Optional[List[str]] = None,
conda_exe: Optional[str] = None,
) -> int:
"""
Shells out to a conda env update command that updates prefix.
:param prefix:
Path to conda env to update.
:param args:
Args to pass to conda env update
:... |
4,402 | 1c745dbe6cd909e39cf30eca0cb058f5 | swh:1:cnt:df80d583eed3ba763d5d569f28fceb656397c598;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=266-284/ | 99deec58e0c1ebd4f9564c7e2cffbe5b00ec9623 | workflow_utils | analytics | workflow_utils/conda.py | conda_install(
prefix: str,
args: Optional[List[str]] = None,
) | function | def conda_install(
prefix: str,
args: Optional[List[str]] = None,
) -> int:
"""
Calls conda install on prefix.
:param prefix:
Path to conda env to update.
:param args:
Args to pass to conda env update
:return:
return code of conda cli command
"""
if args is... |
4,403 | c287b1fe2aea52b417f27474360a72c4 | swh:1:cnt:df80d583eed3ba763d5d569f28fceb656397c598;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=340-436/ | 99deec58e0c1ebd4f9564c7e2cffbe5b00ec9623 | workflow_utils | analytics | workflow_utils/conda.py | conda_create_dist_env(
dist_env_prefix: str,
project_path: Optional[str] = None,
possible_conda_environment_spec_files: Optional[List[str]] = None,
possible_conda_requirements_files: Optional[List[str]] = None,
possible_pip_requirements_files: Optional[List[str]] = None,
possible_pip_constraints... | function | def conda_create_dist_env(
dist_env_prefix: str,
project_path: Optional[str] = None,
possible_conda_environment_spec_files: Optional[List[str]] = None,
possible_conda_requirements_files: Optional[List[str]] = None,
possible_pip_requirements_files: Optional[List[str]] = None,
possible_pip_constra... |
4,404 | ff92b883a4407cd70a3ac250ee5a7279 | swh:1:cnt:df80d583eed3ba763d5d569f28fceb656397c598;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=471-559/ | 99deec58e0c1ebd4f9564c7e2cffbe5b00ec9623 | workflow_utils | analytics | workflow_utils/conda.py | conda_dist(argv: Optional[List[str]] = None) | function | def conda_dist(argv: Optional[List[str]] = None) -> None:
if argv is None:
argv = sys.argv[1:]
script_name = os.path.basename(sys.argv[0])
doc = f"""
Usage: {script_name} [options] [<project_path>]
Arguments:
<project_path>
Path to conda / python project to build. If set, the working di... |
4,405 | cd48a9823e84884e053c49556105276c | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=16-48/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | LogHelper | type | class LogHelper: # pylint: disable=too-few-public-methods
"""
Inherit from this class (multi-inheritance is fine) to get
a self.log Logger named after the fully qualified class name
with 'instance_repr' entry for use by logging formatters.
instance_repr is populated by calling __repr__, which
i... |
4,406 | 246c014a5a8451ee8418052630d38fc5 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=155-172/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | instantiate_all(instances_config: dict) | function | def instantiate_all(instances_config: dict) -> dict:
"""
Given a dict of instance config keyed by name,
call instantiate() on each of them, and return
a new dict that keys the name to the instance.
instances_config must be a dict that looks like:
instance_name1:
class_name: my.module.C... |
4,407 | b7fb294ce29c886b690162bcbe4ea8ba | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=279-297/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | fsspec_use_new_pyarrow_api(should_set_hadoop_env_vars: bool = True) | function | def fsspec_use_new_pyarrow_api(should_set_hadoop_env_vars: bool = True) -> None:
"""
Registers hdfs:// filesystems to always use the arrow_hdfs://
implementation. This uses the newer pyarrow HDFS API.
Call this to force fsspec to always use the new pyarrow API
instead of the old one for all hdfs://... |
4,408 | 8698b5b05a0040158456cdb764f615ae | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=405-412/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | setup_logging::inject_instance_name(record: Any) | function | # Since we use instance_repr in the format of the basic logger,
# All log records also need to have an instance_repr entry.
# Add a logging filter to the root logger's handlers to
# make sure that instance_repr is set if a child logger hasn't set it.
def inject_instance_name(record: Any) -> bool:
... |
4,409 | 3a7880ce12d77aa3b432d0039a99bc96 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=175-208/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | find_java_home() | function | def find_java_home() -> Optional[str]:
"""
Looks for first JAVA_HOME that exists using JAVA_HOME,
bigtop-detect-javahome and java -XshowSettings:properties
"""
java_home = None
if "JAVA_HOME" in os.environ:
java_home = os.environ.get("JAVA_HOME")
elif os.path.exists("/usr/lib/bigtop... |
4,410 | f9e1c6ebe51aa1f9631ff105395e84cd | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=300-321/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | sys_path(python_exec: Optional[str] = None) | function | def sys_path(python_exec: Optional[str] = None) -> List[str]:
"""
Looks a sys.path for either the current running python, or
an external python intepreter. If python_exec is set, its
sys.path will be obtained by running a print(sys.path) in a
subprocess.
:param python_exec:
Path to pyt... |
4,411 | e451f6f191971bad80beda5049c44108 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=236-247/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | get_hadoop_classpath() | function | def get_hadoop_classpath() -> Optional[str]:
"""
Uses result of find_hadoop_exec() to call
`hadoop classpath` and returns result.
"""
hadoop = find_hadoop_exec()
if hadoop and os.path.exists(hadoop):
hadoop_classpath = subprocess.check_output([hadoop, "classpath", "--glob"]).decode("utf-... |
4,412 | d26b6d3d570183866e352897a1f9ce92 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=379-416/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | setup_logging(level: Optional[str] = None) | function | # NOTE: i dunno about this.
def setup_logging(level: Optional[str] = None) -> None:
"""
Configures basic logging defaults.
If level is not given, but the environment variable LOG_LEVEL
is set, it will be used as the level. Otherwise INFO is the default level.
An instance_repr entry will be added t... |
4,413 | a0bc59d52d232a5fcf10e88d72845310 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=32-45/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | LogHelper::__init__(self) | function | def __init__(self) -> None:
"""
Creates a class instance specific logger as self.log using __repr__.
Your implementing class should probably call
super().__init__() from its __init__ method to get this.
NOTE: Call super().__init__() in your implementing class constructor
... |
4,414 | 099a8157b1d13bc9a0704d571e42ca67 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=47-48/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | LogHelper::__repr__(self) | function | def __repr__(self) -> str:
return self.__class__.__name__ |
4,415 | 4ae5375209561156077eada4d21bc17a | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=250-276/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | set_hadoop_env_vars(force: bool = False) | function | def set_hadoop_env_vars(force: bool = False) -> None:
"""
Sets pyarrow related Hadoop environment variables if they aren't already set.
This automates pyarrow (and fsspec) using the newer pyarrow HDFS API without
forcing the user to manually set these.
See: https://arrow.apache.org/docs/python/files... |
4,416 | 9a2eeec92e74e56abb0dfcdff71498f7 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=68-69/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | filter_files_exist(files: List[str]) | function | def filter_files_exist(files: List[str]) -> List[str]:
return [file for file in files if os.path.exists(file)] |
4,417 | 7203030dff13a0feddd29ed8c9f723e3 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=51-65/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | safe_filename(name: str, maxlen: int = 255) | function | def safe_filename(name: str, maxlen: int = 255) -> str:
"""
Given a string, returns a 'safe' filename.
:param name:
:return: safe filename
"""
keep_chars = [".", "_", "-"]
def safe_char(char: str) -> str:
if char.isalnum() or char in keep_chars:
return char
retu... |
4,418 | d0a4157559c1f4495d93657e02d8fa21 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=60-63/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | safe_filename::safe_char(char: str) | function | def safe_char(char: str) -> str:
if char.isalnum() or char in keep_chars:
return char
return "_" |
4,419 | 18b8e607f7fcac1550392d2b05cfc639 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=72-99/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | find_callable_args(fn: Callable) | function | def find_callable_args(fn: Callable) -> List[str]:
"""
Given a function, inspect its parameters and return the
names of the function parameters that are annotated as a Callable type
:param fn: function to inspect
"""
def _is_callable_param(param: inspect.Parameter) -> bool:
"""
... |
4,420 | 3e5cd09cc165028d5f9cd5bc08cf4e71 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=80-94/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | find_callable_args::_is_callable_param(param: inspect.Parameter) | function | def _is_callable_param(param: inspect.Parameter) -> bool:
"""
Returns true if the Parameter's typing annotation is callable annotation.
Callable annoations are 'Callable', typing.Callable, and collections.abc.Callable.
:param param: parameter to check if annotation is a callable annotat... |
4,421 | 790e3e28230909adc1f59b3617cbdb13 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=102-116/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | import_symbol(symbol_full_path: str) | function | def import_symbol(symbol_full_path: str) -> Any:
"""Helper method to instantiate symbols given their full path.
:param module_path: Symbol's full path, including parent modules.
"""
if "." not in symbol_full_path:
raise ValueError(
f"Cannot import symbol from {symbol_full_path}, it ... |
4,422 | bc08a3a40c3ea2b5c70652ffa25e04dc | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=211-220/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | find_hadoop_home() | function | def find_hadoop_home() -> str:
"""
Looks for first hadoop home that exists in HADOOP_HOME
and other possible locations,
"""
possibilities = [
os.environ.get("HADOOP_HOME", ""),
os.path.join("/", "usr", "lib", "hadoop"),
]
return next(filter(os.path.exists, possibilities), "") |
4,423 | a8bb98a730d9e7e36b7fd7f60280a7a1 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=324-353/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | package_version(package_name: str, python_exec: Optional[str] = None) | function | def package_version(package_name: str, python_exec: Optional[str] = None) -> str:
"""
Uses distlib to look up the version of an installed package.
If python_exec is given, the distribution paths in which to search
for package_name will be be determined using sys_path to
ask the python_exec for its s... |
4,424 | 14708fdab3df6b8041a3447b45c1d096 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=119-152/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | instantiate(class_name: str, **args: Any) | function | def instantiate(class_name: str, **args: Any) -> Any:
"""
Factory method for instantiating classes from
kwargs. class_name is expected to be a fully qualified class name of a
python class that is importable in PYTHONPATH.
:param class_name: a fully qualified class name string
:param **args: Th... |
4,425 | 9b434d20fee89126702e8b0051a5f8c3 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=223-233/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | find_hadoop_exec() | function | def find_hadoop_exec() -> Optional[str]:
"""
Looks for 'hadoop' executable in result of find_hadoop_home()
or shutil.which('hadoop')
"""
hadoop: Optional[str] = None
if os.path.exists(os.path.join(find_hadoop_home(), "bin", "hadoop")):
hadoop = os.path.join(find_hadoop_home(), "bin", "ha... |
4,426 | 2836f57fddefb9bdaf868516f68d9de8 | swh:1:cnt:dea20c6187fbb36d1e11b3fd237e9ce26d0e43cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=356-376/ | ad0de3394093c00d1545028f30df0bf5dfa35f04 | workflow_utils | analytics | workflow_utils/util.py | package_version_cli() | function | def package_version_cli() -> None:
"""
CLI function to call package_version and print result.
"""
script_name = os.path.basename(sys.argv[0])
doc = f"""
Prints the python package version of a package importable
by the given python interpreter executlable.
Usage:
{script_name} [--python-exec=<pyt... |
4,427 | eaab51395522740f0919f0dc8721d2b8 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=11-284/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact | type | class Artifact(LogHelper):
"""
An Artifact is identified by 'id', and
has a source URL and a list of cached URLs.
These URLs are looked up by an ArtifactSource locator
and ArtifactCache locators.
This class exists to do the following:
- Locate artifacts in sources
- Cache those ... |
4,428 | e9b2132a33d176213a5558b194a198a4 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=52-53/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::__repr__(self) | function | def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.name})" |
4,429 | 24deab452ba2076152d2df0955efb39d | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=62-80/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::cache_put(self, force: bool = False, skip_size_check: bool = False) | function | def cache_put(self, force: bool = False, skip_size_check: bool = False) -> None:
"""
Puts the artifact in all of its cache locations.
`force` argument forces putting the artifact into cache
regardless of its existence or size difference. Defaults to False.
`skip_size_check` arg... |
4,430 | 7595f32718f6ec3063fc4921a1cc6187 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=90-100/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::locators(self, must_exist: bool = False) | function | def locators(self, must_exist: bool = False) -> Sequence[ArtifactLocator]:
"""
Returns a list of all AritfactLocators for this artifact,
including ArtifactCaches. The ArtifactSource locator is the
last in the list.
:param must_exist: Only return ArtifactLocators where the artifa... |
4,431 | 48a3ef69f92728233b0fcaa98d461ce2 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=109-114/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::exists_in_cache(self) | function | def exists_in_cache(self) -> bool:
"""
Returns true if this artifact exists at any of its
cached locations.
"""
return len(self.cached_urls(must_exist=True)) > 0 |
4,432 | 789538ed504dca105441b95579bc1c29 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=125-136/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::url(self, must_exist: bool = False) | function | def url(self, must_exist: bool = False) -> Optional[str]:
"""
Returns the first URL of the artifact.
Cached URLs will be preferred over the source URL.
If no URLs have existent artifacts, returns None.
:param must_exist: Only return a URL where the artifact exists.
"""
... |
4,433 | 34c6e0a438f2cc76e3277e6e8eb84a4e | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=146-156/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::cached_url(self, must_exist: bool = False) | function | def cached_url(self, must_exist: bool = False) -> Optional[str]:
"""
Returns the first cached URL for this artifact that exists,
or None if no cached URL exists.
:param must_exist: Only return cached a URL where the artifact exists.
"""
urls = self.cached_urls(must_exist... |
4,434 | f0fb457df5761da84359a268187800d9 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=23-50/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::__init__(
self,
id: str, # pylint: disable=redefined-builtin,invalid-name
source: FsArtifactSource,
caches: Optional[List[FsArtifactCache]] = None,
name: Optional[str] = None,
) | function | def __init__(
self,
id: str, # pylint: disable=redefined-builtin,invalid-name
source: FsArtifactSource,
caches: Optional[List[FsArtifactCache]] = None,
name: Optional[str] = None,
):
"""
:param id:
This will be used to locate the artifact.
... |
4,435 | ed107ab8a085b51c02e45d977463ffbc | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=55-60/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::__str__(self) | function | def __str__(self) -> str:
locators_desc = [
f"{locator.url(self)}\t(exists={locator.exists(self)}, size={locator.size(self)})"
for locator in self.locators()
]
return self.__repr__() + ":\n\t" + "\n\t".join(locators_desc) |
4,436 | 3376a74a5d94f39f3f9fed1bdfa2fd9b | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=82-88/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::cache_delete(self) | function | def cache_delete(self) -> None:
"""
Deletes the artifact from all of its cache locations.
"""
for cache in self.caches:
if cache.exists(self):
cache.delete(self) |
4,437 | 2d66ba563e5a577428ff83e6ed0fa259 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=102-107/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::exists(self) | function | def exists(self) -> bool:
"""
Returns true if this artifact exists at any of its
source or cached locations.
"""
return len(self.locators(must_exist=True)) > 0 |
4,438 | f1a2bbaa65d183a1dcc5618b63ab3f75 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=116-123/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::urls(self, must_exist: bool = False) | function | def urls(self, must_exist: bool = False) -> List[str]:
"""
Returns a list of all artifact URLs, including caches.
The source URL is the last in the list.
:param must_exist: Only return URLs where the artifact exists.
"""
return [locator.url(self) for locator in self.loca... |
4,439 | 211ff9baea3326ff34c34f0469c9fe41 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=138-144/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::cached_urls(self, must_exist: bool = False) | function | def cached_urls(self, must_exist: bool = False) -> List[str]:
"""
Returns cached URLs for this artifact that exist.
:param must_exist: Only return cached URLs where the artifact exists.
"""
return [cache.url(self) for cache in self.caches if not must_exist or cache.exists(self)] |
4,440 | c8e25411cf7919b37a3579e462bc7384 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=159-228/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::factory(
cls,
artifact_config: dict,
available_sources: dict,
available_caches: dict,
default_source_name: Optional[str] = None,
default_cache_names: Optional[List[str]] = None,
name: Optional[str] = None,
) | function | def factory(
cls,
artifact_config: dict,
available_sources: dict,
available_caches: dict,
default_source_name: Optional[str] = None,
default_cache_names: Optional[List[str]] = None,
name: Optional[str] = None,
) -> "Artifact":
"""
Instantiates ... |
4,441 | 39dc3e8aa3db16696cb160af711488d9 | swh:1:cnt:528723f167057bb5112b6aa4751eecea2137df52;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=231-284/ | cb16dbc1a1acd5cfab5ad2a44bed147641636981 | workflow_utils | analytics | workflow_utils/artifact/artifact.py | Artifact::load_artifacts_from_config(cls, config: dict) | function | def load_artifacts_from_config(cls, config: dict) -> dict:
"""
Parses the config to instantiate ArtifactSources, ArtifactCaches
and Artifacts declared with those sources and caches.
The provided config dict is expected to have the keys
'artifact_sources', 'artifact_caches', and ... |
4,442 | e5a9709ae25582c65b21782b41e68ba9 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=38-45/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | cache_key_maven(artifact: Artifact) | function | def cache_key_maven(artifact: Artifact) -> str:
"""Translates a coordinate to a relative maven path,
allowing Maven artifacts to be cached in
a Maven compatible directory hierarchy.
:param artifact: Artifact. artifact.id should be a Maven coordinate.
"""
return maven_artifact_uri(artifact.id) |
4,443 | 6d162147d4214bc86114c468ea55caa5 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=84-89/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::url(self, artifact: Artifact) | function | def url(self, artifact: Artifact) -> str:
"""Returns a full URL to the given artifact in this cache.
:param artifact: Artifact
"""
return os.path.join(self.base_uri, self.cache_key_fn(artifact)) |
4,444 | 697cbdb1b69d72dc6eea3241c6c3097f | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=98-108/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::size(self, artifact: Artifact) | function | def size(self, artifact: Artifact) -> Optional[int]:
"""Retrieve size of artifact in this cache.
:param artifact: Artifact
"""
artifact_url = self.url(artifact)
if not self.fs.exists(artifact_url) or self.fs.isdir(artifact_url):
return None
return int(self.... |
4,445 | 818af7a87e8e2f20fbf26227c47db776 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=29-35/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | cache_key_default(artifact: Artifact) | function | def cache_key_default(artifact: Artifact) -> str:
"""Default cache_key_fn implementation.
Simply returns the artifact name with all its unsafe characters removed.
:param artifact: Artifact
"""
return safe_filename(artifact.name) |
4,446 | f024ca0bf21131d6070898e991047bd8 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=74-79/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::fs(self) | function | def fs(self) -> AbstractFileSystem: # pylint: disable=invalid-name
"""Returns the fsspec's FileSystem object based on this
cache's base_uri.
"""
source_fs, _ = fsspec.core.url_to_fs(self.base_uri, **self.fsspec_options)
return source_fs |
4,447 | ad1f9cab665568d74f19a25d034fb9c6 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=53-71/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::__init__(
self,
base_uri: str,
cache_key_fn: Callable[[Artifact], str] = cache_key_default,
fsspec_options: Optional[Dict[str, Any]] = None,
) | function | def __init__(
self,
base_uri: str,
cache_key_fn: Callable[[Artifact], str] = cache_key_default,
fsspec_options: Optional[Dict[str, Any]] = None,
):
"""Construct the FsArtifactCache object
:param base_uri: Base URI in which to store cached artifacts. This URI should s... |
4,448 | 3e72db62267367e464ad9c58c89284c2 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=81-82/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::__repr__(self) | function | def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.base_uri})" |
4,449 | 6335964846a86aea4c4c42efe88ea3a2 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=91-96/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::exists(self, artifact: Artifact) | function | def exists(self, artifact: Artifact) -> bool:
"""Returns True if artifact exists in this cache.
:param artifact: Artifact
"""
return bool(self.fs.exists(self.url(artifact))) |
4,450 | 3a2357b3c4a7064ed799eb839e8ffcb0 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=110-177/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::put(self, artifact: Artifact) | function | def put(self, artifact: Artifact) -> None:
"""Puts the artifact into its designated cache location,
as determined by its self.url(artifact) method.
:param artifact: Artifact
"""
source_fs = artifact.source.fs(artifact)
source_url = artifact.source.url(artifact)
s... |
4,451 | a091721719141f65db08dd6bb27387b0 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=179-186/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache::delete(self, artifact: Artifact) | function | def delete(self, artifact: Artifact) -> None:
"""Delete artifact from cache.
:param artifact: Artifact
"""
if self.exists(artifact):
self.log.debug(f"Cache delete of {repr(artifact)}")
self.fs.rm(self.url(artifact), recursive=True) |
4,452 | 0a8c1591a267164002c3967a5dd91863 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=203-204/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsMavenArtifactCache::__init__(self, base_uri: str, fsspec_options: Optional[Dict[str, Any]] = None) | function | def __init__(self, base_uri: str, fsspec_options: Optional[Dict[str, Any]] = None):
super().__init__(base_uri, cache_key_fn=cache_key_maven, fsspec_options=fsspec_options) |
4,453 | 7a7e1ef0d974232a561e06e447bb282a | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=48-186/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsArtifactCache | type | class FsArtifactCache(ArtifactLocator):
"""
ArtifactCache for use with any writable fsspec FileSystem.
"""
def __init__(
self,
base_uri: str,
cache_key_fn: Callable[[Artifact], str] = cache_key_default,
fsspec_options: Optional[Dict[str, Any]] = None,
):
"""C... |
4,454 | c545e3a1d2629a9ab92228d6e6fe0bf8 | swh:1:cnt:13ccdc9b73507f8a138d7f252db6fc4842647e7f;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=189-204/ | a7fa711c3e8586f8c2fc132fc1988f6e0de971b2 | workflow_utils | analytics | workflow_utils/artifact/cache.py | FsMavenArtifactCache | type | class FsMavenArtifactCache(FsArtifactCache):
"""DEPRECATED.
This class will be removed in future versions. Leaving it here
for backward compatibility with existing YAML configurations that
reference this class.
Caches Maven based artifacts using their coordinates
in a Maven repository directory... |
4,455 | a4f2fffb5964e80d10bb2f58dfa16c0a | swh:1:cnt:5e0c3fa8f4ca48fb903a9b937aa891349e859bb7;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=11-38/ | 8022835c0fbecb17c21496d832c45080fe5e7fad | workflow_utils | analytics | workflow_utils/artifact/cli.py | main(argv: List[str] = sys.argv[1:]) | function | def main(argv: List[str] = sys.argv[1:]) -> None: # pylint: disable=dangerous-default-value
script_name = os.path.basename(sys.argv[0])
doc = f"""
Usage: {script_name} status <artifact_config_files>...
{script_name} warm [--force] [--skip-size-check] <artifact_config_files>...
{script... |
4,456 | bf602aada36bb2f87ddef67406661729 | swh:1:cnt:48dfd1a401e50836841e6a17edecb93def298325;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=17-48/ | d0cd531b2e6de798802895da3d5b5806d79592dc | workflow_utils | analytics | workflow_utils/artifact/locator.py | ArtifactLocator | type | class ArtifactLocator(ABC, LogHelper):
"""
An ArtifactLocator needs to be able to get an
artifact's URL by artifact, as well as
determine if the artifact exists at that URL.
Both ArtifactSource and ArtifactCache are
ArtifactLocators.
"""
@abstractmethod
def url(self, artifact: Arti... |
4,457 | af83ddbba989e76ed739a98d75f3c511 | swh:1:cnt:48dfd1a401e50836841e6a17edecb93def298325;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=28-33/ | d0cd531b2e6de798802895da3d5b5806d79592dc | workflow_utils | analytics | workflow_utils/artifact/locator.py | ArtifactLocator::url(self, artifact: Artifact) | function | def url(self, artifact: Artifact) -> str:
"""
Gets the URL for the artifact.
:param artifact: artifact, implementation specific.
""" |
4,458 | 6f7157fbbbfe747b30dd2ab8bae5846c | swh:1:cnt:48dfd1a401e50836841e6a17edecb93def298325;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=42-48/ | d0cd531b2e6de798802895da3d5b5806d79592dc | workflow_utils | analytics | workflow_utils/artifact/locator.py | ArtifactLocator::size(self, artifact: Artifact) | function | def size(self, artifact: Artifact) -> Optional[int]:
"""
Gets the file size of the artifact at artifact in bytes,
or None if the file does not exist.
:param artifact: artifact, implementation specific.
""" |
4,459 | 3a53c7f8be15c2288e603fa56b266139 | swh:1:cnt:48dfd1a401e50836841e6a17edecb93def298325;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=36-39/ | d0cd531b2e6de798802895da3d5b5806d79592dc | workflow_utils | analytics | workflow_utils/artifact/locator.py | ArtifactLocator::exists(self, artifact: Artifact) | function | def exists(self, artifact: Artifact) -> bool:
"""
:param artifact: artifact, implementation specific.
""" |
4,460 | 66800f630c37bf3c92c1e798e2183375 | swh:1:cnt:71ed937b1952fbd0a6395324ae40aa383f76060c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=9-45/ | 6a15b104197a55f8a4ad3c7d8975175d1633b1a8 | workflow_utils | analytics | workflow_utils/artifact/maven.py | parse_maven_coordinate(coordinate: str) | function | def parse_maven_coordinate(coordinate: str) -> dict:
"""
Parses a maven coordinate string into a dict of maven coordinate parts.
:param coordinate: Maven coordinate string.
:return:
dict with keys: group_id, artifact_id, packaging, classifier, version
"""
parts = coordinate.split(":")
... |
4,461 | f998fc0b6793da99836178a7fb2a4430 | swh:1:cnt:71ed937b1952fbd0a6395324ae40aa383f76060c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=66-75/ | 6a15b104197a55f8a4ad3c7d8975175d1633b1a8 | workflow_utils | analytics | workflow_utils/artifact/maven.py | maven_artifact_dir(coordinate: Union[str, dict]) | function | def maven_artifact_dir(coordinate: Union[str, dict]) -> str:
"""
Gets the directory path in a maven repository for the maven coordinate.
:param coordinate: Maven coordinate string or dict.
"""
if isinstance(coordinate, str):
coordinate = parse_maven_coordinate(coordinate)
path_parts = c... |
4,462 | d7a5ea9faae8cd10fc1bfb5b6fe288a2 | swh:1:cnt:71ed937b1952fbd0a6395324ae40aa383f76060c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=78-92/ | 6a15b104197a55f8a4ad3c7d8975175d1633b1a8 | workflow_utils | analytics | workflow_utils/artifact/maven.py | maven_artifact_uri(coordinate: Union[str, dict], repo_uri: str = "") | function | def maven_artifact_uri(coordinate: Union[str, dict], repo_uri: str = "") -> str:
"""
Gets the artifact URI to a file in a maven repository.
:param coordinate: Maven coordinate string or dict.
:param repo_uri:
Prefix of the maven repository URI. If set, this
function will return an abso... |
4,463 | f3738ca9f50386a63a3f85a9b3a511b7 | swh:1:cnt:71ed937b1952fbd0a6395324ae40aa383f76060c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=48-63/ | 6a15b104197a55f8a4ad3c7d8975175d1633b1a8 | workflow_utils | analytics | workflow_utils/artifact/maven.py | maven_artifact_filename(coordinate: Union[str, dict]) | function | def maven_artifact_filename(coordinate: Union[str, dict]) -> str:
"""
Gets the filename in a maven repository for the maven coordinate.
:param coordinate: Maven coordinate string or dict.
"""
if isinstance(coordinate, str):
coordinate = parse_maven_coordinate(coordinate)
# pylint: disa... |
4,464 | 13d7c4975db88eb75ec9e589ea45e460 | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=24-106/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | FsArtifactSource | type | class FsArtifactSource(ArtifactLocator):
"""
Source of artifacts retrievable via fsspec URIs.
All protocols supported by fsspec are supported.
E.g. local fs, HDFS, HTTP, etc.
For FsArtifactSource, the artifact id should be a URI.
:param base_uri:
Base URI to prefix to all URI artifact_... |
4,465 | e1daec4358082ad4194cb8d8d120d777 | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=109-142/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | MavenArtifactSource | type | class MavenArtifactSource(FsArtifactSource):
"""
Source of artifacts in a Maven repository.
This just translates between a Maven coordinate
and a URL in a Maven repository, and uses
FsArtifactSource to open the file.
For MavenArtifactSource, the artifact_id should
be a Maven coordinate.
... |
4,466 | 2c4128ecdcb1937641e07fb55332f57a | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=48-67/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | FsArtifactSource::fs(self, artifact: Artifact) | function | def fs(self, artifact: Artifact) -> AbstractFileSystem: # pylint: disable=invalid-name
"""
Returns the fsspec's FileSystem object based on this
Artifact's url.
:param artifact: Artifact
"""
source_url = self.url(artifact)
source_url_fsclass = known_implementatio... |
4,467 | 0e26ca41fa84995ec588836acbd60e5f | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=72-81/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | FsArtifactSource::url(self, artifact: Artifact) | function | def url(self, artifact: Artifact) -> str:
"""
For FsArtifactSource, the url is the artifact_id prefixed
with the source's base_uri.
:param artifact: Artifact
"""
if self.base_uri:
return os.path.join(self.base_uri, artifact.id)
return artifact.id |
4,468 | 5c5179d62171113bbda6049918fd4ecc | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=43-46/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | FsArtifactSource::__init__(self, base_uri: Optional[str] = None, fsspec_options: Optional[Dict[str, Any]] = None) | function | def __init__(self, base_uri: Optional[str] = None, fsspec_options: Optional[Dict[str, Any]] = None):
self.base_uri: Optional[str] = base_uri
self.fsspec_options = fsspec_options or {}
super().__init__() |
4,469 | e26d36ce501fde87813930f2d5b7c717 | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=69-70/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | FsArtifactSource::__repr__(self) | function | def __repr__(self) -> str:
return f'{self.__class__.__name__}({self.base_uri or ""})' |
4,470 | 77106b15f71361082629d0e46732fa64 | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=83-88/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | FsArtifactSource::exists(self, artifact: Artifact) | function | def exists(self, artifact: Artifact) -> bool:
"""Returns True if artifact exists in this source.
:param artifact_id: a URI
"""
return bool(self.fs(artifact).exists(self.url(artifact))) |
4,471 | bf5a30873dc624e679b66968a0ddc9f9 | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=90-106/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | FsArtifactSource::size(self, artifact: Artifact) | function | def size(self, artifact: Artifact) -> Optional[int]:
"""Retrieve size of artifact in this source.
:param artifact_id: a URI
"""
source_fs = self.fs(artifact)
artifact_url = self.url(artifact)
if not source_fs.exists(artifact_url) or (
source_fs.fsid != "http... |
4,472 | 8e3c55b4604d94ceadb33847f3d165ac | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=120-133/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | MavenArtifactSource::__init__(self, base_uri: str, fsspec_options: Optional[Dict[str, Any]] = None) | function | def __init__(self, base_uri: str, fsspec_options: Optional[Dict[str, Any]] = None):
"""
:param base_uri:
Base URI to a Maven repository. Required.
E.g. https://archiva.wikimedia.org/repository/mirror-maven-central
:param fsspec_options:
Optional dict of extr... |
4,473 | 7501103bb3f0c489493ea8b9cdf8739c | swh:1:cnt:33a3f2097a8f8ef92553002be5bf9932291e2f8c;origin=https://gitlab.wikimedia.org/repos/data-engineering/workflow_utils.git;lines=135-142/ | 238645e0905f9e2fe8a9fcfed87d1ee20f0f8c04 | workflow_utils | analytics | workflow_utils/artifact/source.py | MavenArtifactSource::url(self, artifact: Artifact) | function | def url(self, artifact: Artifact) -> str:
"""
For MavenArtifactSource, the artifact_id is a Maven coordinate.
:param artifact: Artifact. artifact.id is A maven coordinate string.
"""
# Make sure artifact_id looks like a coorindate.
return maven_artifact_uri(artifact.id,... |
4,474 | 44e36978d8efd9e21d8a5a606353b77f | swh:1:cnt:ab9376dc0a9d3825a1ed5eb53ceb3e3252e070dc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=22-27/ | 6c625f9db1ab2b0d876b6f013e322a5bf4fd7d9f | 3D | deployed | modules/mmv.3d.js | ThreeD | function | function ThreeD( viewer ) {
THREE.Cache.enabled = true;
this.viewer = viewer;
this.$container = viewer.ui.canvas.$imageDiv;
} |
4,475 | 7ce1b3918d4fdb62e745e6a39f814966 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | bn | type | class bn{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===mn&&(mn=sn("canvas")),mn.width=e.width,mn.height=e.height;const i=mn.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawIma... |
4,476 | 2fcdb1da435d59c087145d0b5b3fb2d3 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | cr | type | class cr{constructor(e,t,i,n,r,a,s,o,c,l,h,u,d,A,p,g){cr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,i,n,r,a,s,o,c,l,h,u,d,A,p,g)}set(e,t,i,n,r,a,s,o,c,l,h,u,d,A,p,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=i,f[12]=n,f[1]=r,f[5]=a,f[9]=s,f[13]=o,f[2]=c,f[6]=l,... |
4,477 | dea6d6b1c405b9bed9379ee24b580df4 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | fs | type | class fs extends Ma{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,a=t/2,s=Math.floor(i),o=Math.floor(n),c=s+1,l=o+1,h=e/s,u=t/o,d=[],A=[],p=[],g=[];for(let e=0;e<l;e++){const t=e*u-a;for(let i=0;i<c;i++){const n=i*h-r;A.pus... |
4,478 | b5a3a9eed54d5b90f9de968b6c6c2abc | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | rs | type | class rs extends Ur{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new is(ns,1,e,t);n.layers=this.layers,this.add(n);const r=new is(ns,1,e,t);r.layers=this.layers,this.add(r);const a=new is(ns,1,e,t);a.layers=this.layers,this.add(a);cons... |
4,479 | c527bfb9212a19e8d562d796f11340a0 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Qh | type | class Qh extends yn{constructor(e,t,i,n,r,a,s,o,c){super(e,t,i,n,r,a,s,o,c),this.isCanvasTexture=!0,this.needsUpdate=!0}} |
4,480 | 70a544819093b1d31c6a2fc8b8154997 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Md | type | class Md{constructor(e,t,i,n){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=fd(t,this.TimeBufferType),this.values=fd(i,this.ValueBufferType),this.setInterpolation(n||... |
4,481 | abe839395cba0aa5c3f0e0d253e68092 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Wd | type | class Wd extends Od{constructor(e){super(e)}load(e,t,i,n){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Nd.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a;const s=sn("img");function o(){l(),Nd.add(e,this),t&&t(this),r.manager.... |
4,482 | a2432e0da52aedbf631c7007b12e78d7 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | xA | type | class xA extends Od{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}set... |
4,483 | 65ad632eba25774fb67a7044adbb4536 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | TA | type | class TA{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new is,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new is,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,e... |
4,484 | 7a0ac70a0c98204d0f5e03e54e961290 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | ZA | type | class ZA{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Vi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPa... |
4,485 | 891b8cdd7d955e466f9b3c2ce9966a02 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Eg | type | class Eg{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=tg.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name... |
4,486 | e3e5c8f19741af4ea7a40282309b32e5 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | rp | type | class rp extends Oi{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:np++}),this.name="",this.usage=Ii,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}... |
4,487 | b43dd3ce7f79bc79c0e84f4e8d841129 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | vp | type | class vp extends Ur{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Ma,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,i=32;e<i;e++,t++){const r=e/i*Math.PI*2,a=t/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(a... |
4,488 | 95a61cf8542ecefac40b540e4833453c | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | dp | type | class dp{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.... |
4,489 | a220c61479dfae137b1ca8ab2c7c5e8a | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Cn | type | class Cn{constructor(e=0,t=0,i=0,n=1){Cn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}... |
4,490 | 664ab119041c9a821e38af0b4215825f | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Ur | type | class Ur extends Oi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_r++}),this.uuid=Vi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ur.DEFAULT_UP.clone();const e=new Ln,t=new br,i=new Rn,n=new Ln(1,1,1);t._onChange(function(){i.setFromEuler(t,!1)}),i._on... |
4,491 | a6902a22e31cd1d41bbb2728efd4ff38 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | ta | type | class ta extends ea{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new br,this.combi... |
4,492 | 5aba1c0d51de2543ed18588cc3dd782d | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Ma | type | class Ma extends Oi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:va++}),this.uuid=Vi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,th... |
4,493 | 18bcdabf42f4092841d8f61a052b32df | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | el | type | class el{constructor(e={}){const{canvas:t=on(),context:n=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;let d;this.isWebGLRenderer=!0,d=null!==n?n.getContextAttributes().alpha:s;const f=new Uint32... |
4,494 | 4cc249a6f24d448c4fb784aa34841120 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Bh | type | class Bh extends Ur{constructor(e=new Ma,t=new Ih){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry... |
4,495 | 47b5326d66ea66570d51cb48064223b1 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Jh | type | class Jh extends Fh{constructor(e=new $i,t=new $i,i=new $i,n=new $i){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new $i){const i=t,n=this.v0,r=this.v1,a=this.v2,s=this.v3;return i.set(Yh(e,n.x,r.x,a.x,s.x),Yh(e,n.y,r.y,a.y,s.y)),i}copy(e){return s... |
4,496 | 658a070e8f26816de5a3fbe02333f202 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | lu | type | class lu extends Ma{constructor(e=1,t=1,i=1,n=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};const c=this;n=Math.floor(n),r=Math.floor(r);const l=[],h=[],u=[],d=[];let A=0;co... |
4,497 | 697609b0b248467786a562f212f69c5e | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | mu | type | class mu extends Ma{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const i=4,n=Math.pow(10,i),r=Math.cos(Hi*t),a=e.getIndex(),s=e.getAttribute("position"),o=a?a.count:s.count,c=[0,0,0],l=["a","b","c"],h=new Array(3),u={},d=[];for(let e=0;e<o;e+=3){a?... |
4,498 | 00d38c93bacf3fb8684b652eac9bb6e4 | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | hd | type | class hd extends ea{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Kr(16777215),this.specular=new Kr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kr(0),this.emissiveIntensity=... |
4,499 | e35012ebcfbf998bac511b8f4ba9ea8e | swh:1:cnt:be74c3579b5363eb79f06cff064cd3a615bd1ecc;origin=https://gerrit.wikimedia.org/r/mediawiki/extensions/3D.git;lines=2-2/ | c74be198cc8f55ea5c6bd42cc70f0c8872bd4ae2 | 3D | deployed | modules/lib/three/three.js | Kp | type | class Kp extends Od{constructor(e){super(e)}load(e,t,i,n){const r=this,a=new Hd(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(i){try{t(r.parse(i))}catch(t){n?n(t):console.error(t),r.manager.itemErro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.