Python Toolkit for Rally
Switch branches/tags
Nothing to show
Clone or download
klehman-rally Merge pull request #148 from virtualsnake/master
Fix issue with exception in case of ProfileImage field, add ProfileImage to list of available entity classes
Latest commit 72b9ad8 Nov 5, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist Merge pull request #145 from klehman-rally/master Aug 10, 2018
dists added generated distributions for 1.4.2 release Aug 10, 2018
doc fixed defect in when pagesize is 1, upped version to 1.4.2 Aug 10, 2018
examples disqualifed a bunch of standard attributes of type COLLECTION when re… Apr 4, 2017
pyral Fix issue with exception in case of ProfileImage field Oct 31, 2018
test altered test_search to use internal_rally_targets for creds Jan 9, 2018
LICENSE fixed project scoping, fixed RallyRESTResponse __repr__ for empty res… Mar 20, 2017
MANIFEST multithreading support, new default pagesize of 500, fixed getAllUsers Mar 31, 2017 added working addCollectionItems to, non-working dropColle… Oct 26, 2016
PKG-INFO added generated distributions for 1.4.2 release Aug 10, 2018
README.rst fixed defect in when pagesize is 1, upped version to 1.4.2 Aug 10, 2018
README.short fixed defect in when pagesize is 1, upped version to 1.4.2 Aug 10, 2018
VERSIONS updated README.rst and VERSIONS to mention 1.3.2 change Aug 3, 2017 fixed defect in when pagesize is 1, upped version to 1.4.2 Aug 10, 2018 added doc for add/drop collection convenience methods, explicit requi… Nov 5, 2016
setup.cfg added doc for add/drop collection convenience methods, explicit requi… Nov 5, 2016 fixed defect in when pagesize is 1, upped version to 1.4.2 Aug 10, 2018
template.cfg prep for GitHub push Jan 27, 2012
trial.cfg mods incorporating changes to support Rally WSAPI v2.0 Apr 28, 2014 adjusted getAllowedValues so that custom fields with an allowedValues… Apr 8, 2017


pyral - A Python toolkit for the Agile Central (Rally) REST API

The pyral package enables you to push, pull and otherwise wrangle the data in your Agile Central (formerly named Rally) subscription using the popular and productive Python language. The pyral package provides a smooth and easy to use veneer on top of the Agile Central (Rally) REST Web Services API using JSON.

As of July 2015, the Rally Software Development company was acquired by CA Technologies. The Rally product itself has been rebranded as 'Agile Central'. Over time, the documentation will transition from using the term 'Rally' to using 'Agile Central'.

Getting started

Agile Central (Rally) has created a Python package that you can quickly leverage to interact with the data in your subscription via the REST web services API. You can create, read, update, and delete the common artifacts and other entities via the Python toolkit for Agile Central (Rally).


Files are available at the download page .

The git repository is available at


If you want to pull down the latest release from standard Python package repository ( and install the package, the easiest way is to use pip, the Python package installation utility.:

pip install pyral

Alternatively, if you've got the tar.gz or zip distribution on hand, as long as you've satisfied the dependency requirements on the six and requests packages, you can use the setup mechanism. Obtain the requests package and install it according to that package's directions. As of requests-2.0.0, there is support for HTTPS over HTTP proxy via the CONNECT request. Use of requests-2.x or better is recommended for use with pyral. The requests package can be found via the Python Package Index site (http://pypi/ The most recent release of pyral (1.4.2) has been tested using requests 2.19.1.

Obtain and install the six module (available from PyPI at

Unpack the pyral distribution file (zip or tar.gz) and then install the pyral package.

python install

Use whatever setup options you need for your particular Python environment.

Sanity Check

Fire up a command line Python interpreter. Attempt to import the relevant packages.

$ python
Python 3.6.4 [other Python interpreter info elided ...]
>> import requests
>> import pyral
>> pyral.__version__
(1, 4, 2)

30 second highlight

Since Python is a very flexible and extensible language, we were able to make access to the object model extremely simple. For example, if you have a a UserStory instance returned by a pyral operation assigned to the name story, the following code iterates over the tasks.

for task in story.Tasks:
   print task.Name

There is no need to make a separate call to fetch all the tasks for the story. When you follow domain model attributes in the Python code, the Python toolkit for Agile Central (Rally) REST API machinery automatically loads in the necessary objects for you.

Full Documentation

The complete documentation for the Python toolkit for Agile Central (Rally) REST API is in the doc/build/html subdirectory in the repository. The rendered version of this is also available at

Sample code

Common setup code

import sys
from pyral import Rally, rallyWorkset
options = [arg for arg in sys.argv[1:] if arg.startswith('--')]
args    = [arg for arg in sys.argv[1:] if arg not in options]
server, user, password, apikey, workspace, project = rallyWorkset(options)
rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project)
Show a TestCase identified by the FormattedID value.
Copy the above boilerplate and the following code fragment and save it in a file named
query_criteria = 'FormattedID = "%s"' % args[0]
response = rally.get('TestCase', fetch=True, query=query_criteria)
if response.errors:
for testCase in response:  # there should only be one qualifying TestCase
    print "%s %s %s %s" % (testCase.Name, testCase.Type,
                           testCase.DefectStatus, testCase.LastVerdict)
  • Run it by providing the FormattedID value of your targeted TestCase as a command line argument

    python TC1184

Get a list of workspaces and projects for your subscription
Copy the above boilerplate and the following code fragment and save it in a file called
workspaces = rally.getWorkspaces()
for wksp in workspaces:
    print "%s %s" % (wksp.oid, wksp.Name)
    projects = rally.getProjects(workspace=wksp.Name)
    for proj in projects:
        print "    %12.12s  %s" % (proj.oid, proj.Name)
  • Run the script


Get a list of all users in a specific workspace
Copy the above boilerplate and the following code fragment and save it in a file called
all_users = rally.getAllUsers()
    for user in all_users:
        tz   = user.UserProfile.TimeZone or 'default'
        role = user.Role or '-No Role-'
        values = (int(user.oid), user.Name, user.UserName, role, tz)
        print("%12.12d %-24.24s %-30.30s %-12.12s" % values)
  • Run the script

    python --rallyWorkspace="Product Engineering"

Create a new Defect
Copy the above boilerplate and the following code fragment and save it in a file called
proj = rally.getProject()

# get the first (and hopefully only) user whose DisplayName is 'Sally Submitter'
user = rally.getUserInfo(name='Sally Submitter').pop(0)

defect_data = { "Project" : proj.ref, "SubmittedBy" : user.ref,
                "Name" : name, "Severity" : severity, "Priority" : priority,
                "State" : "Open", "ScheduleState" : "Defined",
                "Description" : description }
    defect = rally.create('Defect', defect_data)
except Exception, details:
    sys.stderr.write('ERROR: %s \n' % details)
print "Defect created, ObjectID: %s  FormattedID: %s" % (defect.oid, defect.FormattedID)
  • Run the script

    python <Name> <severity> <priority> <description>

    making sure to provide valid severity and priority values for your workspace

Update an existing Defect
Copy the above boilerplate and the following code fragment and save it in a file called .
 defectID, customer, target_date, notes = args[:4]
 # target_date must be in ISO-8601 format "YYYY-MM-DDThh:mm:ssZ"

 defect_data = { "FormattedID" : defectID,
                 "Customer"    : customer,
                 "TargetDate"  : target_date,
                 "Notes"       : notes
     defect = rally.update('Defect', defect_data)
 except Exception, details:
     sys.stderr.write('ERROR: %s \n' % details)

print "Defect %s updated" % defect.FormattedID
  • Run the script

    python <Defect FormattedID> <customer> <target_date> <notes text...>

Config Options

The pyral package uses a priority chain of files, environment variables and command line arguments to set the configuration context when an instance of the Rally class is created. See the complete documentation for detailed information on this mechanism. Here's a brief description of how you can specify a configuration when you create an instance of the Rally class.

Configuration file settings

Config file item Description
SERVER Rally server (example
USER Rally subscription UserName value
PASSWORD password for the Rally subscription UserName
APIKEY Rally API Key value
WORKSPACE Rally Workspace
PROJECT Rally Project

The item names in config files are case sensitive.

Command line options

Command line option Description
--rallyConfig=<config_file_name> name of the file with settings for pyral
--config=<config_file_name> ditto
--conf=<config_file_name> ditto
--cfg=<config_file_name> ditto
--rallyUser=<foo> your Rally UserName
--rallyPassword=<bar> password associated with the Rally UserName
--apikey=<APIKey> valid Rally API Key value
--rallyWorkspace=<bar> Workspace in Rally you want to interact with
--rallyProject=<bar> Project in Rally you want to interact with


  • Python 3.5, 3.6 or 3.7 (this package not tested with earlier versions of Python 3.x) OR
  • Python 2.7 (explicit support for this version will end with the 1.4.x line, 1.5.x will not support 2.7)
  • The requests package, 2.0.0 or better (2.0.0 finally includes support for https proxy), requests 2.19.1 is recommended.
  • The six package.


Fixed defect in returning RallyRESTResponse when pagesize set to 1
Support for TestFolderStatus attribute in TestFolder. Fixed defect in addCollectionItems
Support for PullRequest entity object (subclassed from Connection).
Allow for initial connection using a workspace name containing chars that need to be urlencoded.
Adjusted getAllowedValues so that custom fields with an allowedValues endpoint get resolved. Disqualifed a group of standard attributes whose allowedValue is of type COLLECTION when retrieving allowed values in SchemaItem.complete(). This is primarily relevant only to attributes defined as Drop Down List or Multi Value Drop Down List. Fixed mechanism of supplying headers dict to Rally instantiation so that the X-RallyIntegration* headers get overwritten with supplied headers (for name, vendor, version) to better identify the origin of the integration. Updated official name to reference Agile Central in, mention threads keyword arg in the get method in the the interface.rst file.
Introduced automatic multi-threading for Rally.get operation to speed up retrieval of large result sets. Implemented step two of the Pinger deprecation plan, ping=False is the new default. Increased default page size to 500. Maximum useful page size limit is 2000 but 1000 seems to be the sweet spot for multithreading requests. Fixed Rally.getAllUsers so that non subscription admin accounts can see the user list. Updated recommendation for version of requests package.
Fixed handling of projectScopeUp and projectScopeDown keyword arguments for get operation. Fixed Peristable's __getattr__ method to more properly handle getting the salient item out of a response to a getResourceByOID request when the item retrieved is a PortfolioItem sub-type. Fixed defect in SchemaItemAttribute where self._allowed_values_resolved was not always set. Fixed defect in RallyRestResponse in __repr__ method where on a response that has no qualifying items an attempt is made to get the Results out of the returned response without going through the QueryResult key.
Fixed Rally.getAllowedValues method to accommodate custom fields Allow attribute payload for put and post to have a list of pyral.Entity instances as values for an attribute that is of type COLLECTION.
Allow for disambiguating Project amongst name duplications by means of using fully qualified path. Incorporated suggestion on preserving case name of custom PortfolioItem sub-item. Fixed discrepancy of docs versus code on default pagesize, now is actually 200 everywhere. Fix location of download package in GitHub repo.
Added mention that the six package is required. Fixed context setup for proper handling when a user has no default workspace/project settings. Corrected handling of allowedValues for attributes when the single allowedValue is a boolean value. Added an example script.

Support for Python 3.5.x Begin deprecation sequence for pinging the Rally server before the connection attempt, initially with this version, allow option on instantiation to bypass ping. Added ability to rankAbove, rankBelow, rankToTop, rankToBottom for an Artifact. Fixed defect where user has no default workspace or project.

addAttachment now correctly handles binary file, attachment size limit increased to 50MB to match Agile Central limit. Exception generated when running getAllUsers when credentials are for non Subscription/Workspace Administrator has been fixed. Added ability to work with a single Workspace, which has beneficial performance effect for Subscriptions with a large number of Workspaces. Modified internal attribute handling to limit calls to get attribute's allowed values to qualifying attribute types. Added examples/ script.

see the VERSIONS file for information pertaining to older releases


  • Dynamically construct the Agile Central (Rally) schema class hierarchy economically.


BSD3-style license. Copyright (c) 2015-2017 CA Technologies, 2010-2015 Rally Software Development.

See the LICENSE file provided with the source distribution for full details.


None. See the LICENSE file for full text regarding this issue.


The use of this package is on an as-is basis and there is no official support offered by CA Technologies. The author of this module periodically checks the GitHub repository issues for this package in the interests of providing defect fixes and small feature enhancements as time permits, but is not obligated to respond or take action. Posts to Stack Overflow ( are another avenue to engage others who have some exposure to pyral and might be able to offer useful information.


Additional Credits

  • GitHub for repository hosting services.
  • ReadTheDocs for documentation hosting services.