【问题标题】:Unable to extract all feature data for a project using pyral's rest api python无法使用 pyral 的 rest api python 提取项目的所有特征数据
【发布时间】:2020-11-12 02:54:33
【问题描述】:

我正在尝试使用 pyral 模块读取 Rally 中项目的所有特征数据。结果集总数为 1358,脚本在读取约 700 条记录后抛出如下所述的错误。

rally1 = Rally(entity='PortfolioItem_Feature',server='rally1.rallydev.com',fetch=True, user='xxx', password='', workspace='xxx/yyy', project='ABC')
features = rally1.get('Feature',fetch="True",pagesize=2000,start=0,limit=5000)

for feature in features:
    #a=pd.DataFrame(feature)
    print(feature.details())

输出:

PortfolioItem/Feature result set, totalResultSetSize: 1358, startIndex: 1  pageSize: 2000  current Index: 0
I'm getting the following errors:

File "C:\Users\nis\AppData\Roaming\Python\Python38\site-packages\pyral\entity.py", line 397, in details
    (attr_name, cln, value.oid, value.UserName, value.DisplayName)
  File "C:\Users\nis\AppData\Roaming\Python\Python38\site-packages\pyral\entity.py", line 139, in __getattr__
    raise UnreferenceableOIDError("%s OID %s" % (rallyEntityTypeName, self.oid))
pyral.entity.UnreferenceableOIDError: User OID 44012386960

所以,我有以下问题:

  1. 如何解决此错误,即跳过读取要素属性的特定字段或将其替换为空结果集。
  2. 如何将 (a) (b) PortfolioItem/Feature 结果集转换为数据框,而不会出现上述错误。

我正在使用下面的代码,这个脚本也读了大约。 700 条记录并引发与上述相同的错误。我尝试使用错误处理,但它仍然在遇到错误时停止读取。任何帮助将不胜感激。

r=pd.DataFrame()
for feature in features:
 a= {
 'OID': feature.oid,
 'FeatureID':feature.FormattedID,
 'Creation_Date': feature.CreationDate,
  'Project_Name': feature.Project.Name,
  'AcceptedLeafStoryPlanEstimateTotal':feature.AcceptedLeafStoryPlanEstimateTotal,
  'AcceptedLeafStoryPlanEstimateTotal':feature.AcceptedLeafStoryPlanEstimateTotal,
  'Feature_payload':feature._ref,
  'Created by':feature.CreatedBy.DisplayName
 }
 #print(a.keys())
 #print(a.values())
 r=r.append(a,ignore_index=True,sort=False)
 print(r)

【问题讨论】:

    标签: python api rest rally pyral


    【解决方案1】:

    在我看来,ID 为 44012386960 的对象已损坏,因此您必须跳过它。

    for feature in features:
        if feature.oid == 44012386960:
            continue
        print(feature.details())
    

    我假设您的错误是一个错误的 featureoid,因为它也发生在您的第二个循环中,它只使用 feature.oid 但也有可能 feature.CreatedBy 是问题,因为您的错误消息表明它是一个错误的用户 oid .在这种情况下,我的建议是在循环中打印 feature.CreatedBy.oid 以找到坏的并将我的 if 更改为 if feature.CreatedBy.oid == 44012386960: continue

    【讨论】:

      【解决方案2】:

      我在python中使用三元运算符解决了这个问题,如下所示:

      feature_name = '' if feature.Feature is None else feature.Feature.Name
      

      问题是每当 Rally rest api 无法引用导致错误的特定功能的 oid 时。

      【讨论】:

      • 第一个答案就是这么说的,糟糕的功能 oid。
      猜你喜欢
      • 1970-01-01
      • 2023-02-10
      • 2017-08-26
      • 1970-01-01
      • 2021-08-22
      • 2021-09-07
      • 2016-10-15
      • 1970-01-01
      • 2018-02-02
      相关资源
      最近更新 更多