python-2.7rallypyral

Pyral Cannot Parse Parent Object returned


I am trying to get the Parent Epic / Feature for particular User Stories in Rally. However I am only getting the parent object and I am not sure how to parse it. I have tried dict and dir(object) to get field values but it did not work. I have also tried as following, but I keep on getting something like this instead of fields/values in Parent Object

pyral.entity.PortfolioItem_Capability object at 0x7ff848273850

CODE:

def get_hierarchy(server,username,password,workspace,project,release):
   rally = Rally(server, username, password, workspace=workspace, project=project)
   criterion = 'Release.Name = "'+release+'" AND Parent != None'
   response = rally.get('HierarchicalRequirement',fetch="ObjectID,FormattedID,Name,AcceptedDate,Project,Release,ScheduleState,Parent,Description",query=criterion,limit=5000)
   return response  
for item in get_hierarchy("rally1.rallydev.com","some.email@address.com","Somepassword","Some Workspace Name","PROJECT NAME","Release Version"):
   print item.FormattedID, item.Name, item.ScheduleState, item.Description, item.Parent.Name

Solution

  • The parent is also an object and you have to parse the parent similar to the user story. For a simplistic solution, keep using the dot format. Here is a code snippet that does something similar to the above that should give you a start.

        queryString = '(Iteration.StartDate > "2017-08-31")'
        entityName = 'HierarchicalRequirement'
        response = rally.get(entityName, fetch=True, projectScopeDown=True, query=queryString)
    
        for item in response:
            print(item.FormattedID,
                 item.PortfolioItem.FormattedID,
                 item.PortfolioItem.Parent.FormattedID,
                 item.PlanEstimate)
    

    I'm using Python 3.x but I don't see any reason it wouldn't translate to 2.7.