taskgraph.util package


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_projects(project, run_on_projects)

Determine whether the given project is included in the run-on-projects parameter, applying expansions for things like “integration” mentioned in the attribute documentation.

taskgraph.util.bbb_validation module


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.

  • 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 indentifying 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.cached_tasks.cached_index_path(level, trust_domain, cache_type, cache_name, digest=None, digest_data=None)

Get the index path needed to locate the task that would be created by add_optimization().

  • level (int) – The SCM level of the task to look for.
  • trust_domain (str) – The trust domain to look for the task in.
  • 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 indentifying 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.
Return str:

The index path.

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.

class taskgraph.util.docker.VoidWriter

Bases: object

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

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

Create a context tarball.

A directory context_dir containing a Dockerfile will be assembled into a gzipped tar file at out_path. Files inside the archive will be prefixed by directory prefix.

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, image_name, args=None)

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


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


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, prefix, args=None)

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

taskgraph.util.hash module


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.parameterization module

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

Resolve all instances of {‘task-reference’: ‘..<..>..’} 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.partials module


Convert build platform names into balrog platform names

taskgraph.util.partials.get_builds(release_history, platform, locale)

Examine cached balrog release history and return the list of builds we need to generate diffs from

taskgraph.util.partials.get_partials_artifact_map(release_history, platform, locale)
taskgraph.util.partials.get_partials_artifacts(release_history, platform, locale)
taskgraph.util.partials.get_sorted_releases(product, branch)

Returns a list of release names from Balrog. :param product: product name, AKA appName :param branch: branch name, e.g. mozilla-central :return: a sorted list of release names, most recent first.

taskgraph.util.partials.populate_release_history(product, branch, maxbuilds=4, maxsearch=10, partial_updates=None)

taskgraph.util.platforms module


Given a build platform, return the platform family (linux, macosx, etc.)

taskgraph.util.push_apk module

Common functions for both push-apk and push-apk-breakpoint.

taskgraph.util.push_apk.delete_non_required_fields_transform(_, jobs)
taskgraph.util.push_apk.fill_labels_tranform(_, jobs)
taskgraph.util.push_apk.validate_dependent_tasks_transform(_, jobs)
taskgraph.util.push_apk.validate_jobs_schema_transform_partial(description_schema, transform_type, config, jobs)

taskgraph.util.python_path module


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.schema module

taskgraph.util.schema.Schema(*args, **kwargs)

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


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, **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:

    test-platform: linux128
            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:

    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:

                ash: ..
                cedar: ..
        linux: 13
        default: 12
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.scriptworker module

Make scriptworker.cot.verify more user friendly by making scopes dynamic.

Scriptworker uses certain scopes to determine which sets of credentials to use. Certain scopes are restricted by branch in chain of trust verification, and are checked again at the script level. This file provides functions to adjust these scopes automatically by project; this makes pushing to try, forking a project branch, and merge day uplifts more user friendly.

In the future, we may adjust scopes by other settings as well, e.g. different scopes for push-to-candidates rather than push-to-releases, even if both happen on mozilla-beta and mozilla-release.

Additional configuration is found in the graph config.

taskgraph.util.scriptworker.BALROG_SCOPE_ALIAS_TO_PROJECT = [[u'nightly', set([u'mozilla-central'])], [u'beta', set([u'mozilla-beta'])], [u'release', set([u'mozilla-release'])], [u'esr', set([u'mozilla-esr52'])]]

Map the balrog scope aliases to the actual scopes.

taskgraph.util.scriptworker.BALROG_SERVER_SCOPES = {u'aurora': u'balrog:server:aurora', u'beta': u'balrog:server:beta', u'default': u'balrog:server:dep', u'esr': u'balrog:server:esr', u'nightly': u'balrog:server:nightly', u'release': u'balrog:server:release'}

Map the balrog scope aliases to the actual channel scopes.

taskgraph.util.scriptworker.BEETMOVER_ACTION_SCOPES = {u'all-candidates-tasks': u'beetmover:action:push-to-candidates', u'all-nightly-tasks': u'beetmover:action:push-to-nightly', u'all-push-tasks': u'beetmover:action:push-to-releases', u'default': u'beetmover:action:push-to-staging'}

Map the beetmover tasks aliases to phases.

taskgraph.util.scriptworker.BEETMOVER_BUCKET_SCOPES = {u'all-candidates-tasks': {u'all-release-branches': u'beetmover:bucket:release'}, u'all-nightly-tasks': {u'all-nightly-branches': u'beetmover:bucket:nightly'}, u'all-push-tasks': {u'all-release-branches': u'beetmover:bucket:release'}, u'default': u'beetmover:bucket:dep'}

Map the beetmover tasks aliases to the actual action scopes.

taskgraph.util.scriptworker.BEETMOVER_RELEASE_TARGET_TASKS = set([u'push_devedition', u'push_fennec', u'promote_firefox', u'promote_fennec', u'ship_firefox', u'ship_fennec', u'push_firefox', u'ship_devedition', u'promote_devedition'])

Map beetmover tasks aliases to sets of target task methods.

This is a list of list-pairs, for ordering.

taskgraph.util.scriptworker.BEETMOVER_SCOPE_ALIAS_TO_PROJECT = [[u'all-nightly-branches', set([u'mozilla-beta', u'mozilla-release', u'mozilla-central'])], [u'all-release-branches', set([u'mozilla-release', u'mozilla-beta'])]]

The set of all beetmover release target tasks.

Used for both BEETMOVER_SCOPE_ALIAS_TO_TARGET_TASK and get_release_build_number

taskgraph.util.scriptworker.BEETMOVER_SCOPE_ALIAS_TO_TARGET_TASK = [[u'all-nightly-tasks', set([u'nightly_linux', u'nightly_fennec', u'nightly_macosx', u'mozilla_beta_tasks', u'nightly_win64', u'mozilla_release_tasks', u'nightly_desktop', u'nightly_win32'])], [u'all-candidates-tasks', set([u'promote_devedition', u'promote_firefox', u'promote_fennec'])], [u'all-push-tasks', set([u'push_devedition', u'push_fennec', u'push_firefox', u'ship_fennec', u'ship_devedition', u'ship_firefox'])]]

Map the beetmover scope aliases to the actual scopes.

taskgraph.util.scriptworker.DEVEDITION_SIGNING_CERT_SCOPES = {u'beta': u'signing:cert:nightly-signing', u'default': u'signing:cert:dep-signing'}

Map beetmover scope aliases to sets of projects.

taskgraph.util.scriptworker.PHASES = {u'all-candidates-tasks': u'promote', u'all-push-tasks': u'push', u'default': None}

Map balrog scope aliases to sets of projects.

This is a list of list-pairs, for ordering.

taskgraph.util.scriptworker.PUSH_APK_SCOPES = {u'beta': u'googleplay:beta', u'central': u'googleplay:aurora', u'default': u'googleplay:invalid', u'release': u'googleplay:release'}

The list of the release promotion phases which we send notifications for

taskgraph.util.scriptworker.SIGNING_SCOPE_ALIAS_TO_PROJECT = [[u'all-nightly-branches', set([u'mozilla-central'])], [u'all-release-branches', set([u'mozilla-release', u'mozilla-beta'])]]

Map the signing scope aliases to the actual scopes.

taskgraph.util.scriptworker.add_scope_prefix(config, scope)

Prepends the scriptworker scope prefix from the graph config.

  • config (TransformConfig) – The configuration for the kind being transformed.
  • scope (string) – The suffix of the scope

the scope to use.

Return type:


taskgraph.util.scriptworker.get_phase_from_target_method(config, alias_to_tasks_map, alias_to_phase_map)

Determine the phase from config.params[‘target_tasks_method’].

  • config (TransformConfig) – The configuration for the kind being transformed.
  • alias_to_tasks_map (list of lists) – each list pair contains the alias and the set of target methods that match. This is ordered.
  • alias_to_phase_map (dict) – the alias to phase map

the phase to use.

Return type:



Get the build number and version for a release task.

Currently only applies to beetmover tasks.

Parameters:config (TransformConfig) – The configuration for the kind being transformed.
containing both build_number and version. This can be used to
update task.payload.
Return type:dict
taskgraph.util.scriptworker.get_scope_from_project(config, **kwargs)

Determine the restricted scope from config.params[‘project’].

  • config (TransformConfig) – The configuration for the kind being transformed.
  • alias_to_project_map (list of lists) – each list pair contains the alias and the set of projects that match. This is ordered.
  • alias_to_scope_map (dict) – the alias alias to scope

the scope to use.

Return type:


taskgraph.util.scriptworker.get_scope_from_target_method(config, **kwargs)

Determine the restricted scope from config.params[‘target_tasks_method’].

  • config (TransformConfig) – The configuration for the kind being transformed.
  • alias_to_tasks_map (list of lists) – each list pair contains the alias and the set of target methods that match. This is ordered.
  • alias_to_scope_map (dict) – the alias alias to scope

the scope to use.

Return type:


taskgraph.util.scriptworker.get_scope_from_target_method_and_project(config, **kwargs)

Determine the restricted scope from both target_tasks_method and project.

On certain branches, we’ll need differing restricted scopes based on target_tasks_method. However, we can’t key solely on that, since that target_tasks_method might be run on an unprivileged branch. This method checks both.

  • config (TransformConfig) – The configuration for the kind being transformed.
  • alias_to_tasks_map (list of lists) – each list pair contains the alias and the set of target methods that match. This is ordered.
  • alias_to_project_map (list of lists) – each list pair contains the alias and the set of projects that match. This is ordered.
  • aliases_to_scope_map (dict of dicts) – the task alias to project alias to scope

the scope to use.

Return type:


taskgraph.util.scriptworker.get_signing_cert_scope_per_platform(build_platform, is_nightly, config)
taskgraph.util.scriptworker.get_worker_type_for_scope(config, scope)

Get the scriptworker type that will accept the given scope.

  • config (TransformConfig) – The configuration for the kind being transformed.
  • scope (string) – The scope being used.

The worker-type to use.

Return type:



Wraps a function, calling add_scope_prefix() on the result of calling the wrapped function.

Parameters:f (callable) – A function that takes a config and some keyword arguments, and returns a scope suffix.
Returns:the wrapped function
Return type:callable

taskgraph.util.seta module

class taskgraph.util.seta.SETA

Bases: object

Interface to the SETA service, which defines low-value tasks that can be optimized out of the taskgraph.

is_low_value_task(label, project, pushlog_id, push_date, bbb_task=False)
minutes_between_pushes(project, cur_push_id, cur_push_date)
query_low_value_tasks(project, bbb=False)

taskgraph.util.signed_artifacts module

Defines artifacts to sign before repackage.

taskgraph.util.signed_artifacts.generate_specifications_of_artifacts_to_sign(build_platform, is_nightly=False, keep_locale_template=True, kind=None)

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_url(task_id, path, use_proxy=False)
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_task_definition(task_id, use_proxy=False)
taskgraph.util.taskcluster.get_task_url(task_id, use_proxy=False)
taskgraph.util.taskcluster.get_taskcluster_artifact_prefix(task_id, postfix=u'', locale=None)
taskgraph.util.taskcluster.list_artifacts(task_id, use_proxy=False)
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.purge_cache(provisioner_id, worker_type, cache_name, use_proxy=False)

Requests a cache purge from the purge-caches service.

taskgraph.util.templates module


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.

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

taskgraph.util.time module

exception taskgraph.util.time.InvalidString

Bases: exceptions.Exception

exception taskgraph.util.time.UnknownTimeMeasurement

Bases: exceptions.Exception

Parameters:datetime_format (boolean) – Set True to get a datetime output
Returns:JSON string representation of the current time.
taskgraph.util.time.json_time_from_now(input_str, now=None, datetime_format=False)
  • 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

JSON string representation of time in future.


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.treeherder module

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.


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

taskgraph.util.verify module

class taskgraph.util.verify.VerificationSequence

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.

taskgraph.util.verify.verify_always_optimized(task, taskgraph, scratch_pad)

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

taskgraph.util.verify.verify_bbb_builders_valid(task, taskgraph, scratch_pad)

This function ensures that any task which is run in buildbot (via buildbot-bridge) is using a recognized buildername.

If you see an unexpected failure with a task due to this check, please see the IRC Channel, #releng.

taskgraph.util.verify.verify_dependency_tiers(task, taskgraph, scratch_pad)
taskgraph.util.verify.verify_docs(filename, identifiers, appearing_as)
taskgraph.util.verify.verify_gecko_v2_routes(task, taskgraph, scratch_pad)

This function ensures that any two tasks have distinct index.v2.routes

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

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

taskgraph.util.workertypes module


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

taskgraph.util.yaml.load_yaml(path, name, enforce_order=False)

Convenience function to load a YAML file in the given path. This is useful for loading kind configuration files from the kind path. If enforce_order is given, then any top-level keys in the file must be given in order.

Module contents