taskgraph.util package

Submodules

taskgraph.util.archive module

taskgraph.util.archive.create_tar_from_files(fp, files)

Create a tar file deterministically.

Receives a dict mapping names of files in the archive to local filesystem paths or mozpack.files.BaseFile instances.

The files will be archived and written to the passed file handle opened for writing.

Only regular files can be written.

FUTURE accept a filename argument (or create APIs to write files)

taskgraph.util.archive.create_tar_gz_from_files(fp, files, filename=None, compresslevel=9)

Create a tar.gz file deterministically from files.

This is a glorified wrapper around create_tar_from_files that adds gzip compression.

The passed file handle should be opened for writing in binary mode. When the function returns, all data has been written to the handle.

taskgraph.util.attributes module

taskgraph.util.attributes.attrmatch(attributes, **kwargs)

Determine whether the given set of task attributes matches. The conditions are given as keyword arguments, where each keyword names an attribute. The keyword value can be a literal, a set, or a callable. A literal must match the attribute exactly. Given a set, the attribute value must be in the set. A callable is called with the attribute value. If an attribute is specified as a keyword argument but not present in the attributes, the result is False.

taskgraph.util.attributes.keymatch(attributes, target)

Determine if any keys in attributes are a match to target, then return a list of matching values. First exact matches will be checked. Failing that, regex matches and finally a default key.

taskgraph.util.attributes.match_run_on_git_branches(git_branch, run_on_git_branches)

Determine whether the given project is included in the run-on-git-branches parameter. Allows ‘all’.

taskgraph.util.attributes.match_run_on_projects(key, run_on)

Determine whether the given parameter is included in the corresponding run-on-attribute.

taskgraph.util.attributes.match_run_on_tasks_for(key, run_on)

Determine whether the given parameter is included in the corresponding run-on-attribute.

taskgraph.util.attributes.sorted_unique_list(*args)

Join one or more lists, and return a sorted list of unique members

taskgraph.util.cached_tasks module

taskgraph.util.cached_tasks.add_optimization(config, taskdesc, cache_type, cache_name, digest=None, digest_data=None)

Allow the results of this task to be cached. This adds index routes to the task so it can be looked up for future runs, and optimization hints so that cached artifacts can be found. Exactly one of digest and digest_data must be passed.

Parameters
  • config (TransformConfig) – The configuration for the kind being transformed.

  • taskdesc (dict) – The description of the current task.

  • cache_type (str) – The type of task result being cached.

  • cache_name (str) – The name of the object being cached.

  • digest (bytes or None) – A unique string identifying this version of the artifacts being generated. Typically this will be the hash of inputs to the task.

  • digest_data (list of bytes or None) – A list of bytes representing the inputs of this task. They will be concatenated and hashed to create the digest for this task.

taskgraph.util.decision module

Utilities for generating a decision task from .taskcluster.yml.

taskgraph.util.decision.make_decision_task(params, root, context, head_rev=None)

Generate a basic decision task, based on the root .taskcluster.yml

taskgraph.util.docker module

class taskgraph.util.docker.HashingWriter(writer)

Bases: object

A file object with write capabilities that hashes the written data at the same time it passes down to a real file object.

hexdigest()
write(buf)
class taskgraph.util.docker.VoidWriter

Bases: object

A file object with write capabilities that does nothing with the written data.

write(buf)
taskgraph.util.docker.create_context_tar(topsrcdir, context_dir, out_path, args=None)

Create a context tarball.

A directory context_dir containing a Dockerfile will be assembled into a gzipped tar file at out_path.

We also scan the source Dockerfile for special syntax that influences context generation.

If a line in the Dockerfile has the form # %include <path>, the relative path specified on that line will be matched against files in the source repository and added to the context under the path topsrcdir/. If an entry is a directory, we add all files under that directory.

If a line in the Dockerfile has the form # %ARG <name>, occurrences of the string $<name> in subsequent lines are replaced with the value found in the args argument. Exception: this doesn’t apply to VOLUME definitions.

Returns the SHA-256 hex digest of the created archive.

taskgraph.util.docker.docker_image(name, by_tag=False)

Resolve in-tree prebuilt docker image to <registry>/<repository>@sha256:<digest>, or <registry>/<repository>:<tag> if by_tag is True.

taskgraph.util.docker.docker_url(path, **kwargs)
taskgraph.util.docker.generate_context_hash(topsrcdir, image_path, args=None)

Generates a sha256 hash for context directory used to build an image.

taskgraph.util.docker.image_path(name)
taskgraph.util.docker.image_paths()

Return a map of image name to paths containing their Dockerfile.

taskgraph.util.docker.parse_volumes(image)

Parse VOLUME entries from a Dockerfile for an image.

taskgraph.util.docker.post_to_docker(tar, api_path, **kwargs)

POSTs a tar file to a given docker API path.

The tar argument can be anything that can be passed to requests.post() as data (e.g. iterator or file object). The extra keyword arguments are passed as arguments to the docker API.

taskgraph.util.docker.stream_context_tar(topsrcdir, context_dir, out_file, image_name=None, args=None)

Like create_context_tar, but streams the tar file to the out_file file object.

taskgraph.util.hash module

taskgraph.util.hash.hash_path(path)

Hash a single file.

Returns the SHA-256 hash in hex form.

taskgraph.util.hash.hash_paths(base_path, patterns)

Give a list of path patterns, return a digest of the contents of all the corresponding files, similarly to git tree objects or mercurial manifests.

Each file is hashed. The list of all hashes and file paths is then itself hashed to produce the result.

taskgraph.util.keyed_by module

taskgraph.util.keyed_by.evaluate_keyed_by(value, item_name, attributes, defer=None, enforce_single_match=True)

For values which can either accept a literal value, or be keyed by some attributes, perform that lookup and return the result.

For example, given item:

by-test-platform:
    macosx-10.11/debug: 13
    win.*: 6
    default: 12

a call to evaluate_keyed_by(item, ‘thing-name’, {‘test-platform’: ‘linux96’) would return 12.

Items can be nested as deeply as desired:

by-test-platform:
    win.*:
        by-project:
            ash: ..
            cedar: ..
    linux: 13
    default: 12
Parameters
  • value (str) – Name of the value to perform evaluation on.

  • item_name (str) – Used to generate useful error messages.

  • attributes (dict) – Dictionary of attributes used to lookup ‘by-<key>’ with.

  • defer (list) – Allows evaluating a by-* entry at a later time. In the example above it’s possible that the project attribute hasn’t been set yet, in which case we’d want to stop before resolving that subkey and then call this function again later. This can be accomplished by setting defer=[“project”] in this example.

  • enforce_single_match (bool) – If True (default), each task may only match a single arm of the evaluation.

taskgraph.util.memoize module

class taskgraph.util.memoize.memoize(func)

Bases: dict

A decorator to memoize the results of function calls depending on its arguments. Both functions and instance methods are handled, although in the instance method case, the results are cache in the instance itself.

method_call(instance, *args)

taskgraph.util.parameterization module

taskgraph.util.parameterization.resolve_task_references(label, task_def, task_id, decision_task_id, dependencies)

Resolve all instances of {'task-reference': '..<..>..'} `` and ``{'artifact-reference`: '..<dependency/artifact/path>..'} in the given task definition, using the given dependencies.

taskgraph.util.parameterization.resolve_timestamps(now, task_def)

Resolve all instances of {‘relative-datestamp’: ‘..’} in the given task definition

taskgraph.util.path module

Like os.path, with a reduced set of functions, and with normalized path separators (always use forward slashes). Also contains a few additional utilities not found in os.path.

taskgraph.util.path.abspath(path)
taskgraph.util.path.ancestors(path)

Emit the parent directories of a path.

Parameters

path (str) – Path to emit parents of.

Yields

str – Path of parent directory.

taskgraph.util.path.basedir(path, bases)

Given a list of directories (bases), return which one contains the given path. If several matches are found, the deepest base directory is returned.

basedir('foo/bar/baz', ['foo', 'baz', 'foo/bar']) returns 'foo/bar' (‘foo’ and ‘foo/bar’ both match, but ‘foo/bar’ is the deepest match)

taskgraph.util.path.basename(path)
taskgraph.util.path.commonprefix(paths)
taskgraph.util.path.dirname(path)
taskgraph.util.path.join(*paths)
taskgraph.util.path.match(path, pattern)

Return whether the given path matches the given pattern. An asterisk can be used to match any string, including the null string, in one part of the path:

foo matches *, f* or fo*o

However, an asterisk matching a subdirectory may not match the null string:

foo/bar does not match foo/*/bar

If the pattern matches one of the ancestor directories of the path, the patch is considered matching:

foo/bar matches foo

Two adjacent asterisks can be used to match files and zero or more directories and subdirectories.

foo/bar matches foo/**/bar, or **/bar

taskgraph.util.path.normpath(path)
taskgraph.util.path.normsep(path)

Normalize path separators, by using forward slashes instead of whatever os.sep is.

taskgraph.util.path.realpath(path)
taskgraph.util.path.rebase(oldbase, base, relativepath)

Return relativepath relative to base instead of oldbase.

taskgraph.util.path.relpath(path, start)
taskgraph.util.path.split(path)

Return the normalized path as a list of its components.

split('foo/bar/baz') returns ['foo', 'bar', 'baz']

taskgraph.util.path.splitext(path)

taskgraph.util.python_path module

taskgraph.util.python_path.find_object(path)

Find a Python object given a path of the form <modulepath>:<objectpath>. Conceptually equivalent to

def find_object(modulepath, objectpath):

import <modulepath> as mod return mod.<objectpath>

taskgraph.util.python_path.import_sibling_modules(exceptions=None)

Import all Python modules that are siblings of the calling module.

Parameters

exceptions (list) – A list of file names to exclude (caller and __init__.py are implicitly excluded).

taskgraph.util.readonlydict module

class taskgraph.util.readonlydict.ReadOnlyDict(*args, **kwargs)

Bases: dict

A read-only dictionary.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

taskgraph.util.schema module

class taskgraph.util.schema.Schema(*args, check=True, **kwargs)

Bases: voluptuous.schema_builder.Schema

Operates identically to voluptuous.Schema, but applying some taskgraph-specific checks in the process.

extend(*args, **kwargs)

Create a new Schema by merging this and the provided schema.

Neither this Schema nor the provided schema are modified. The resulting Schema inherits the required and extra parameters of this, unless overridden.

Both schemas must be dictionary-based.

Parameters
  • schema – dictionary to extend this Schema with

  • required – if set, overrides required of this Schema

  • extra – if set, overrides extra of this Schema

taskgraph.util.schema.check_schema(schema)
taskgraph.util.schema.optionally_keyed_by(*arguments)

Mark a schema value as optionally keyed by any of a number of fields. The schema is the last argument, and the remaining fields are taken to be the field names. For example:

‘some-value’: optionally_keyed_by(

‘test-platform’, ‘build-platform’, Any(‘a’, ‘b’, ‘c’))

The resulting schema will allow nesting of by-test-platform and by-build-platform in either order.

taskgraph.util.schema.resolve_keyed_by(item, field, item_name, defer=None, enforce_single_match=True, **extra_values)

For values which can either accept a literal value, or be keyed by some other attribute of the item, perform that lookup and replacement in-place (modifying item directly). The field is specified using dotted notation to traverse dictionaries.

For example, given item:

job:
    test-platform: linux128
    chunks:
        by-test-platform:
            macosx-10.11/debug: 13
            win.*: 6
            default: 12

a call to resolve_keyed_by(item, ‘job.chunks’, item[‘thing-name’]) would mutate item in-place to:

job:
    test-platform: linux128
    chunks: 12

The item_name parameter is used to generate useful error messages.

If extra_values are supplied, they represent additional values available for reference from by-<field>.

Items can be nested as deeply as the schema will allow:

chunks:
    by-test-platform:
        win.*:
            by-project:
                ash: ..
                cedar: ..
        linux: 13
        default: 12
Parameters
  • item (dict) – Object being evaluated.

  • field (str) – Name of the key to perform evaluation on.

  • item_name (str) – Used to generate useful error messages.

  • defer (list) – Allows evaluating a by-* entry at a later time. In the example above it’s possible that the project attribute hasn’t been set yet, in which case we’d want to stop before resolving that subkey and then call this function again later. This can be accomplished by setting defer=[“project”] in this example.

  • enforce_single_match (bool) – If True (default), each task may only match a single arm of the evaluation.

  • extra_values (kwargs) – If supplied, represent additional values available for reference from by-<field>.

Returns

item which has also been modified in-place.

Return type

dict

taskgraph.util.schema.validate_schema(schema, obj, msg_prefix)

Validate that object satisfies schema. If not, generate a useful exception beginning with msg_prefix.

taskgraph.util.shell module

taskgraph.util.shell.quote(*strings)

Given one or more strings, returns a quoted string that can be used literally on a shell command line.

>>> quote('a', 'b')
"a b"
>>> quote('a b', 'c')
"'a b' c"

taskgraph.util.taskcluster module

taskgraph.util.taskcluster.cancel_task(task_id, use_proxy=False)

Cancels a task given a task_id. In testing mode, just logs that it would have cancelled.

taskgraph.util.taskcluster.find_task_id(index_path, use_proxy=False)
taskgraph.util.taskcluster.get_artifact(task_id, path, use_proxy=False)

Returns the artifact with the given path for the given task id.

If the path ends with “.json” or “.yml”, the content is deserialized as, respectively, json or yaml, and the corresponding python data (usually dict) is returned. For other types of content, a file-like object is returned.

taskgraph.util.taskcluster.get_artifact_from_index(index_path, artifact_path, use_proxy=False)
taskgraph.util.taskcluster.get_artifact_path(task, path)
taskgraph.util.taskcluster.get_artifact_prefix(task)
taskgraph.util.taskcluster.get_artifact_url(task_id, path, use_proxy=False)
taskgraph.util.taskcluster.get_current_scopes()

Get the current scopes. This only makes sense in a task with the Taskcluster proxy enabled, where it returns the actual scopes accorded to the task.

taskgraph.util.taskcluster.get_index_url(index_path, use_proxy=False, multiple=False)
taskgraph.util.taskcluster.get_purge_cache_url(provisioner_id, worker_type, use_proxy=False)
taskgraph.util.taskcluster.get_root_url(use_proxy)

Get the current TASKCLUSTER_ROOT_URL.

When running in a task, this must come from $TASKCLUSTER_ROOT_URL; when run on the command line, a default may be provided that points to the production deployment of Taskcluster. If use_proxy is set, this attempts to get TASKCLUSTER_PROXY_URL instead, failing if it is not set.

taskgraph.util.taskcluster.get_session()
taskgraph.util.taskcluster.get_task_definition(task_id, use_proxy=False)
taskgraph.util.taskcluster.get_task_url(task_id, use_proxy=False)
taskgraph.util.taskcluster.list_artifacts(task_id, use_proxy=False)
taskgraph.util.taskcluster.list_task_group_incomplete_tasks(task_group_id)

Generate the incomplete tasks in a task group

taskgraph.util.taskcluster.list_tasks(index_path, use_proxy=False)

Returns a list of task_ids where each task_id is indexed under a path in the index. Results are sorted by expiration date from oldest to newest.

taskgraph.util.taskcluster.parse_time(timestamp)

Turn a “JSON timestamp” as used in TC APIs into a datetime

taskgraph.util.taskcluster.purge_cache(provisioner_id, worker_type, cache_name, use_proxy=False)

Requests a cache purge from the purge-caches service.

taskgraph.util.taskcluster.requests_retry_session(retries, backoff_factor=0.1, status_forcelist=(500, 502, 503, 504), concurrency=50, session=None)
taskgraph.util.taskcluster.rerun_task(task_id)

Reruns a task given a task_id. In testing mode, just logs that it would have reran.

taskgraph.util.taskcluster.send_email(address, subject, content, link, use_proxy=False)

Sends an email using the notify service

taskgraph.util.taskcluster.state_task(task_id, use_proxy=False)

Gets the state of a task given a task_id.

In testing mode, just logs that it would have retrieved state. This is a subset of the data returned by status_task().

Parameters
  • task_id (str) – A task id.

  • use_proxy (bool) – Whether to use taskcluster-proxy (default: False)

Returns

The state of the task, one of

pending, running, completed, failed, exception, unknown.

Return type

str

taskgraph.util.taskcluster.status_task(task_id, use_proxy=False)

Gets the status of a task given a task_id.

In testing mode, just logs that it would have retrieved status.

Parameters
  • task_id (str) – A task id.

  • use_proxy (bool) – Whether to use taskcluster-proxy (default: False)

Returns

A dictionary object as defined here:

https://docs.taskcluster.net/docs/reference/platform/queue/api#status

Return type

dict

taskgraph.util.taskgraph module

Tools for interacting with existing taskgraphs.

taskgraph.util.taskgraph.find_decision_task(parameters, graph_config)

Given the parameters for this action, find the taskId of the decision task

taskgraph.util.taskgraph.find_existing_tasks_from_previous_kinds(full_task_graph, previous_graph_ids, rebuild_kinds)

Given a list of previous decision/action taskIds and kinds to ignore from the previous graphs, return a dictionary of labels-to-taskids to use as existing_tasks in the optimization step.

taskgraph.util.templates module

taskgraph.util.templates.merge(*objects)

Merge the given objects, using the semantics described for merge_to, with objects later in the list taking precedence. From an inheritance perspective, “parents” should be listed before “children”.

Returns the result without modifying any arguments.

taskgraph.util.templates.merge_to(source, dest)

Merge dict and arrays (override scalar values)

Keys from source override keys from dest, and elements from lists in source are appended to lists in dest.

Parameters
  • source (dict) – to copy from

  • dest (dict) – to copy to (modified in place)

taskgraph.util.time module

exception taskgraph.util.time.InvalidString

Bases: Exception

exception taskgraph.util.time.UnknownTimeMeasurement

Bases: Exception

taskgraph.util.time.current_json_time(datetime_format=False)
Parameters

datetime_format (boolean) – Set True to get a datetime output

Returns

JSON string representation of the current time.

taskgraph.util.time.days(value)
taskgraph.util.time.hours(value)
taskgraph.util.time.json_time_from_now(input_str, now=None, datetime_format=False)
Parameters
  • input_str (str) – Input string (see value of)

  • now (datetime) – Optionally set the definition of now

  • datetime_format (boolean) – Set True to get a datetime output

Returns

JSON string representation of time in future.

taskgraph.util.time.minutes(value)
taskgraph.util.time.months(value)
taskgraph.util.time.seconds(value)
taskgraph.util.time.value_of(input_str)

Convert a string to a json date in the future :param str input_str: (ex: 1d, 2d, 6years, 2 seconds) :returns: Unit given in seconds

taskgraph.util.time.years(value)

taskgraph.util.treeherder module

taskgraph.util.treeherder.add_suffix(treeherder_symbol, suffix)

Add a suffix to a treeherder symbol that may contain a group.

taskgraph.util.treeherder.inherit_treeherder_from_dep(job, dep_job)

Inherit treeherder defaults from dep_job

taskgraph.util.treeherder.join_symbol(group, symbol)

Perform the reverse of split_symbol, combining the given group and symbol. If the group is ‘?’, then it is omitted.

taskgraph.util.treeherder.replace_group(treeherder_symbol, new_group)

Add a suffix to a treeherder symbol that may contain a group.

taskgraph.util.treeherder.split_symbol(treeherder_symbol)

Split a symbol expressed as grp(sym) into its two parts. If no group is given, the returned group is ‘?’

taskgraph.util.vcs module

class taskgraph.util.vcs.GitRepository(path)

Bases: taskgraph.util.vcs.Repository

property all_remote_names

Name of all configured remote repositories.

property base_rev

Hash of revision the current topic branch is based on.

property branch

Current branch or bookmark the checkout has active.

property default_branch

Name of the default branch.

default_remote_name = 'origin'
does_revision_exist_locally(revision)

Check whether this revision exists in the local repository.

If this function returns an unexpected value, then make sure the revision was fetched from the remote repository.

find_latest_common_revision(base_ref_or_rev, head_rev)

Find the latest revision that is common to both the given head_rev and base_ref_or_rev

get_changed_files(diff_filter='ADM', mode='unstaged', rev=None, base_rev=None)
Return a list of files that are changed in:
  • either this repository’s working copy,

  • or at a given revision (rev)

  • or between 2 revisions (base_rev and rev)

diff_filter controls which kinds of modifications are returned. It is a string which may only contain the following characters:

A - Include files that were added D - Include files that were deleted M - Include files that were modified

By default, all three will be included.

mode can be one of ‘unstaged’, ‘staged’ or ‘all’. Only has an effect on git. Defaults to ‘unstaged’.

rev is a specifier for which changesets to consider for changes. The exact meaning depends on the vcs system being used.

base_rev specifies the range of changesets. This parameter cannot be used without rev. The range includes rev but excludes base_rev.

get_commit_message(revision=None)

Commit message of specified revision or current commit.

get_outgoing_files(diff_filter='ADM', upstream=None)

Return a list of changed files compared to upstream.

diff_filter works the same as get_changed_files. upstream is a remote ref to compare against. If unspecified, this will be determined automatically. If there is no remote ref, a MissingUpstreamRepo exception will be raised.

get_url(remote='origin')

Get URL of the upstream repository.

property head_rev

Hash of HEAD revision.

property remote_name

Name of the remote repository.

tool = 'git'
update(ref)

Update the working directory to the specified reference.

working_directory_clean(untracked=False, ignored=False)

Determine if the working directory is free of modifications.

Returns True if the working directory does not have any file modifications. False otherwise.

By default, untracked and ignored files are not considered. If untracked or ignored are set, they influence the clean check to factor these file classes into consideration.

class taskgraph.util.vcs.HgRepository(*args, **kwargs)

Bases: taskgraph.util.vcs.Repository

property all_remote_names

Name of all configured remote repositories.

property base_rev

Hash of revision the current topic branch is based on.

property branch

Current branch or bookmark the checkout has active.

property default_branch

Name of the default branch.

default_remote_name = 'default'
does_revision_exist_locally(revision)

Check whether this revision exists in the local repository.

If this function returns an unexpected value, then make sure the revision was fetched from the remote repository.

find_latest_common_revision(base_ref_or_rev, head_rev)

Find the latest revision that is common to both the given head_rev and base_ref_or_rev

get_changed_files(diff_filter='ADM', mode='unstaged', rev=None, base_rev=None)
Return a list of files that are changed in:
  • either this repository’s working copy,

  • or at a given revision (rev)

  • or between 2 revisions (base_rev and rev)

diff_filter controls which kinds of modifications are returned. It is a string which may only contain the following characters:

A - Include files that were added D - Include files that were deleted M - Include files that were modified

By default, all three will be included.

mode can be one of ‘unstaged’, ‘staged’ or ‘all’. Only has an effect on git. Defaults to ‘unstaged’.

rev is a specifier for which changesets to consider for changes. The exact meaning depends on the vcs system being used.

base_rev specifies the range of changesets. This parameter cannot be used without rev. The range includes rev but excludes base_rev.

get_commit_message(revision=None)

Commit message of specified revision or current commit.

get_outgoing_files(diff_filter='ADM', upstream=None)

Return a list of changed files compared to upstream.

diff_filter works the same as get_changed_files. upstream is a remote ref to compare against. If unspecified, this will be determined automatically. If there is no remote ref, a MissingUpstreamRepo exception will be raised.

get_url(remote='default')

Get URL of the upstream repository.

property head_rev

Hash of HEAD revision.

property remote_name

Name of the remote repository.

tool = 'hg'
update(ref)

Update the working directory to the specified reference.

working_directory_clean(untracked=False, ignored=False)

Determine if the working directory is free of modifications.

Returns True if the working directory does not have any file modifications. False otherwise.

By default, untracked and ignored files are not considered. If untracked or ignored are set, they influence the clean check to factor these file classes into consideration.

class taskgraph.util.vcs.Repository(path)

Bases: abc.ABC

NULL_REVISION = '0000000000000000000000000000000000000000'
abstract property all_remote_names

Name of all configured remote repositories.

abstract property base_rev

Hash of revision the current topic branch is based on.

abstract property branch

Current branch or bookmark the checkout has active.

abstract property default_branch

Name of the default branch.

abstract property default_remote_name

Name the VCS defines for the remote repository when cloning it for the first time. This name may not exist anymore if users changed the default configuration, for instance.

abstract does_revision_exist_locally(revision)

Check whether this revision exists in the local repository.

If this function returns an unexpected value, then make sure the revision was fetched from the remote repository.

abstract find_latest_common_revision(base_ref_or_rev, head_rev)

Find the latest revision that is common to both the given head_rev and base_ref_or_rev

abstract get_changed_files(diff_filter, mode='unstaged', rev=None, base_rev=None)
Return a list of files that are changed in:
  • either this repository’s working copy,

  • or at a given revision (rev)

  • or between 2 revisions (base_rev and rev)

diff_filter controls which kinds of modifications are returned. It is a string which may only contain the following characters:

A - Include files that were added D - Include files that were deleted M - Include files that were modified

By default, all three will be included.

mode can be one of ‘unstaged’, ‘staged’ or ‘all’. Only has an effect on git. Defaults to ‘unstaged’.

rev is a specifier for which changesets to consider for changes. The exact meaning depends on the vcs system being used.

base_rev specifies the range of changesets. This parameter cannot be used without rev. The range includes rev but excludes base_rev.

abstract get_commit_message(revision=None)

Commit message of specified revision or current commit.

abstract get_outgoing_files(diff_filter, upstream)

Return a list of changed files compared to upstream.

diff_filter works the same as get_changed_files. upstream is a remote ref to compare against. If unspecified, this will be determined automatically. If there is no remote ref, a MissingUpstreamRepo exception will be raised.

abstract get_url(remote=None)

Get URL of the upstream repository.

abstract property head_rev: str

Hash of HEAD revision.

abstract property remote_name

Name of the remote repository.

run(*args: str, **kwargs)
abstract property tool: str

Version control system being used, either ‘hg’ or ‘git’.

abstract update(ref)

Update the working directory to the specified reference.

abstract working_directory_clean(untracked=False, ignored=False)

Determine if the working directory is free of modifications.

Returns True if the working directory does not have any file modifications. False otherwise.

By default, untracked and ignored files are not considered. If untracked or ignored are set, they influence the clean check to factor these file classes into consideration.

taskgraph.util.vcs.find_hg_revision_push_info(repository, revision)

Given the parameters for this action and a revision, find the pushlog_id of the revision.

taskgraph.util.vcs.get_repository(path)

Get a repository object for the repository at path. If path is not a known VCS repository, raise an exception.

taskgraph.util.verify module

class taskgraph.util.verify.GraphVerification(func, run_on_projects=None)

Bases: taskgraph.util.verify.Verification

Verification for a TaskGraph object.

verify(graph: taskgraph.taskgraph.TaskGraph, graph_config: taskgraph.config.GraphConfig, parameters: taskgraph.parameters.Parameters)
class taskgraph.util.verify.InitialVerification(func)

Bases: taskgraph.util.verify.Verification

Verification that doesn’t depend on any generation state.

verify()
class taskgraph.util.verify.KindsVerification(func)

Bases: taskgraph.util.verify.Verification

Verification for kinds.

verify(kinds: dict)
class taskgraph.util.verify.ParametersVerification(func)

Bases: taskgraph.util.verify.Verification

Verification for a set of parameters.

verify(parameters: taskgraph.parameters.Parameters)
class taskgraph.util.verify.Verification(func)

Bases: abc.ABC

abstract verify(**kwargs) None
class taskgraph.util.verify.VerificationSequence(verifications=NOTHING)

Bases: object

Container for a sequence of verifications over a TaskGraph. Each verification is represented as a callable taking (task, taskgraph, scratch_pad), called for each task in the taskgraph, and one more time with no task but with the taskgraph and the same scratch_pad that was passed for each task.

add(name, **kwargs)
taskgraph.util.verify.verify_always_optimized(task, taskgraph, scratch_pad, graph_config, parameters)

This function ensures that always-optimized tasks have been optimized.

taskgraph.util.verify.verify_dependency_tiers(task, taskgraph, scratch_pad, graph_config, parameters)
taskgraph.util.verify.verify_routes_notification_filters(task, taskgraph, scratch_pad, graph_config, parameters)

This function ensures that only understood filters for notifications are specified.

See: https://docs.taskcluster.net/reference/core/taskcluster-notify/docs/usage

taskgraph.util.verify.verify_task_graph_symbol(task, taskgraph, scratch_pad, graph_config, parameters)

This function verifies that tuple (collection.keys(), machine.platform, groupSymbol, symbol) is unique for a target task graph.

taskgraph.util.verify.verify_toolchain_alias(task, taskgraph, scratch_pad, graph_config, parameters)

This function verifies that toolchain aliases are not reused.

taskgraph.util.verify.verify_trust_domain_v2_routes(task, taskgraph, scratch_pad, graph_config, parameters)

This function ensures that any two tasks have distinct index.{trust-domain}.v2 routes.

taskgraph.util.workertypes module

taskgraph.util.workertypes.get_worker_type(graph_config, alias, level)

Get the worker type based, evaluating aliases from the graph config.

taskgraph.util.workertypes.worker_type_implementation(graph_config, worker_type)

Get the worker implementation and OS for the given workerType, where the OS represents the host system, not the target OS, in the case of cross-compiles.

taskgraph.util.yaml module

class taskgraph.util.yaml.UnicodeLoader(stream)

Bases: yaml.loader.SafeLoader

construct_yaml_str(node)
yaml_constructors = {'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>, 'tag:yaml.org,2002:omap': <function SafeConstructor.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function UnicodeLoader.construct_yaml_str>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:map': <function SafeConstructor.construct_yaml_map>, None: <function SafeConstructor.construct_undefined>}
taskgraph.util.yaml.load_stream(stream)

Parse the first YAML document in a stream and produce the corresponding Python object.

taskgraph.util.yaml.load_yaml(*parts)

Convenience function to load a YAML file in the given path. This is useful for loading kind configuration files from the kind path.

Module contents