Bug 1302765 - Allow `./mach taskgraph .. --parameters P` to take a URL. URL building mechanism fixed; r?dustin
MozReview-Commit-ID: 7reezQj9Bds
--- a/taskcluster/docs/how-tos.rst
+++ b/taskcluster/docs/how-tos.rst
@@ -27,27 +27,30 @@ more common changes to the task graph wi
complexity when the transition is complete.
Hacking Task Graphs
-------------------
The recommended process for changing task graphs is this:
1. Find a recent decision task on the project or branch you are working on,
- and download its ``parameters.yml`` from the Task Inspector. This file
+ and download its ``parameters.yml`` from the Task Inspector or you can
+ simply take note of the ``URL`` of the file or the ``task-id``. This file
contains all of the inputs to the task-graph generation process. Its
contents are simple enough if you would like to modify it, and it is
documented in :doc:`parameters`.
2. Run one of the ``mach taskgraph`` subcommands (see :doc:`taskgraph`) to
generate a baseline against which to measure your changes. For example:
.. code-block:: none
./mach taskgraph tasks --json -p parameters.yml > old-tasks.json
+ ./mach taskgraph tasks --json -p url/to/parameters.yml > old-tasks.json
+ ./mach taskgraph tasks --json -p task-id=<task-id> > old-tasks.json
3. Make your modifications under ``taskcluster/``.
4. Run the same ``mach taskgraph`` command, sending the output to a new file,
and use ``diff`` to compare the old and new files. Make sure your changes
have the desired effect and no undesirable side-effects.
5. When you are satisfied with the changes, push them to try to ensure that the
--- a/taskcluster/taskgraph/parameters.py
+++ b/taskcluster/taskgraph/parameters.py
@@ -56,18 +56,34 @@ class Parameters(ReadOnlyDict):
except KeyError:
raise KeyError("taskgraph parameter {!r} not found".format(k))
def load_parameters_file(options):
"""
Load parameters from the --parameters option
"""
+ import urllib
+
+ url_prefix = "https://queue.taskcluster.net/v1/task/"
+ url_postfix = "/artifacts/public/parameters.yml"
+
filename = options['parameters']
+
if not filename:
return Parameters()
- with open(filename) as f:
- if filename.endswith('.yml'):
- return Parameters(**yaml.safe_load(f))
- elif filename.endswith('.json'):
- return Parameters(**json.load(f))
- else:
- raise TypeError("Parameters file `{}` is not JSON or YAML".format(filename))
+
+ try:
+ # reading parameters from a local parameters.yml file
+ f = open(filename)
+ except IOError:
+ # fetching parameters.yml using task task-id or supplied url
+ if filename.startswith("task-id="):
+ task_id = filename.split("=")[1]
+ filename = url_prefix + task_id + url_postfix
+ f = urllib.urlopen(filename)
+
+ if filename.endswith('.yml'):
+ return Parameters(**yaml.safe_load(f))
+ elif filename.endswith('.json'):
+ return Parameters(**json.load(f))
+ else:
+ raise TypeError("Parameters file `{}` is not JSON or YAML".format(filename))