suite-py 1.44.0__py3-none-any.whl → 1.46.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- suite_py/__version__.py +1 -1
- suite_py/cli.py +22 -0
- suite_py/commands/estimate_cone.py +91 -0
- suite_py/lib/handler/youtrack_handler.py +76 -3
- {suite_py-1.44.0.dist-info → suite_py-1.46.0.dist-info}/METADATA +2 -2
- {suite_py-1.44.0.dist-info → suite_py-1.46.0.dist-info}/RECORD +8 -7
- {suite_py-1.44.0.dist-info → suite_py-1.46.0.dist-info}/WHEEL +0 -0
- {suite_py-1.44.0.dist-info → suite_py-1.46.0.dist-info}/entry_points.txt +0 -0
suite_py/__version__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
__version__ = "1.
|
|
2
|
+
__version__ = "1.46.0"
|
suite_py/cli.py
CHANGED
|
@@ -265,6 +265,28 @@ def cli_unlock_project(obj, environment):
|
|
|
265
265
|
obj.call(ProjectLock, env=environment, action="unlock").run()
|
|
266
266
|
|
|
267
267
|
|
|
268
|
+
@main.command(
|
|
269
|
+
"estimate-cone",
|
|
270
|
+
help="Point-in-time estimate of the time needed to complete all unresolved children of a card using the Cone of Uncertainty",
|
|
271
|
+
)
|
|
272
|
+
@click.option("--issue", prompt="Issue ID", type=str)
|
|
273
|
+
@click.option("--sprint-board", prompt="Sprint Board ID", type=str)
|
|
274
|
+
@click.option("--previous-sprints", required=False, type=int, default=6)
|
|
275
|
+
@click.pass_obj
|
|
276
|
+
@catch_exceptions
|
|
277
|
+
def estimate_cone(
|
|
278
|
+
obj: Context,
|
|
279
|
+
issue: Optional[str],
|
|
280
|
+
sprint_board: Optional[str],
|
|
281
|
+
previous_sprints: int,
|
|
282
|
+
):
|
|
283
|
+
from suite_py.commands.estimate_cone import EstimateCone
|
|
284
|
+
|
|
285
|
+
obj.call(EstimateCone).run(
|
|
286
|
+
issue=issue, sprint_board=sprint_board, previous_sprints=previous_sprints
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
|
|
268
290
|
@main.command("open-pr", help="Open a PR on GitHub")
|
|
269
291
|
@click.pass_obj
|
|
270
292
|
@catch_exceptions
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
from suite_py.lib import metrics
|
|
3
|
+
from suite_py.lib.handler.youtrack_handler import YoutrackHandler
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class EstimateCone:
|
|
7
|
+
def __init__(self, project, config, tokens):
|
|
8
|
+
self._project = project
|
|
9
|
+
self._config = config
|
|
10
|
+
self._youtrack = YoutrackHandler(config, tokens)
|
|
11
|
+
|
|
12
|
+
@metrics.command("estimate-cone")
|
|
13
|
+
def run(self, issue: str, sprint_board: str, previous_sprints: int):
|
|
14
|
+
remaining_story_points = self._sum_of_unresolved_descendant_story_points(issue)
|
|
15
|
+
|
|
16
|
+
current_sprint = self._youtrack.get_current_sprint(sprint_board)
|
|
17
|
+
sprints = self._youtrack.get_sprints(sprint_board)
|
|
18
|
+
|
|
19
|
+
current_sprint_index = next(
|
|
20
|
+
(
|
|
21
|
+
index
|
|
22
|
+
for index, sprint in enumerate(sprints)
|
|
23
|
+
if sprint["id"] == current_sprint["id"]
|
|
24
|
+
),
|
|
25
|
+
None,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
recent_sprints = sprints[
|
|
29
|
+
current_sprint_index - previous_sprints : current_sprint_index
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
sprints_resolved_story_points = [
|
|
33
|
+
self._youtrack.get_sprint_resolved_story_points(sprint_board, sprint["id"])
|
|
34
|
+
for sprint in recent_sprints
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
average_story_points_per_sprint = sum(sprints_resolved_story_points) / len(
|
|
38
|
+
sprints_resolved_story_points
|
|
39
|
+
)
|
|
40
|
+
max_story_points_per_sprint = (
|
|
41
|
+
max(sprints_resolved_story_points) or 1
|
|
42
|
+
) # Avoid division by zero
|
|
43
|
+
min_story_points_per_sprint = (
|
|
44
|
+
min(sprints_resolved_story_points) or 1
|
|
45
|
+
) # Avoid division by zero
|
|
46
|
+
|
|
47
|
+
average_estimate = remaining_story_points / average_story_points_per_sprint
|
|
48
|
+
best_estimate = remaining_story_points / max_story_points_per_sprint
|
|
49
|
+
worst_estimate = remaining_story_points / min_story_points_per_sprint
|
|
50
|
+
|
|
51
|
+
print(f"Remaining story points: {remaining_story_points}")
|
|
52
|
+
|
|
53
|
+
print(f"Max story points per sprint: {max_story_points_per_sprint}")
|
|
54
|
+
print(f"Average story points per sprint: {average_story_points_per_sprint:.2f}")
|
|
55
|
+
print(f"Min story points per sprint: {min_story_points_per_sprint}")
|
|
56
|
+
|
|
57
|
+
print(f"Average estimate: {average_estimate:.2f} sprints")
|
|
58
|
+
print(f"Best estimate: {best_estimate:.2f} sprints")
|
|
59
|
+
print(f"Worst estimate: {worst_estimate:.2f} sprints")
|
|
60
|
+
|
|
61
|
+
print(f"Sprints resolved story points: {sprints_resolved_story_points}")
|
|
62
|
+
|
|
63
|
+
def _sum_of_unresolved_descendant_story_points(self, _issue_readable_id):
|
|
64
|
+
descendants = self._youtrack.get_issue_descendants(_issue_readable_id)
|
|
65
|
+
|
|
66
|
+
descendants_digested = [
|
|
67
|
+
{
|
|
68
|
+
"id": descendant.get("idReadable"),
|
|
69
|
+
"summary": descendant.get("summary"),
|
|
70
|
+
"resolved": bool(descendant.get("resolved")),
|
|
71
|
+
"story_points": next(
|
|
72
|
+
(
|
|
73
|
+
field["value"]
|
|
74
|
+
for field in descendant["customFields"]
|
|
75
|
+
if field["name"] == "Story Points"
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
or 0,
|
|
79
|
+
}
|
|
80
|
+
for descendant in descendants
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
for descendant in descendants_digested:
|
|
84
|
+
if not descendant["resolved"]:
|
|
85
|
+
print(descendant)
|
|
86
|
+
|
|
87
|
+
return sum(
|
|
88
|
+
descendant["story_points"]
|
|
89
|
+
for descendant in descendants_digested
|
|
90
|
+
if not descendant["resolved"]
|
|
91
|
+
)
|
|
@@ -23,6 +23,7 @@ WORKABLE_CARD_TYPES = [
|
|
|
23
23
|
]
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
# pylint: disable=too-many-public-methods
|
|
26
27
|
class YoutrackHandler:
|
|
27
28
|
def __init__(self, config, tokens):
|
|
28
29
|
headers = {"Accept": "application/json", "Content-Type": "application/json"}
|
|
@@ -43,9 +44,15 @@ class YoutrackHandler:
|
|
|
43
44
|
|
|
44
45
|
def get_issue(self, issue_id):
|
|
45
46
|
logger.debug(f"YouTrack issue_id: {issue_id}")
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
47
|
+
_fields = [
|
|
48
|
+
"$type",
|
|
49
|
+
"id",
|
|
50
|
+
"idReadable",
|
|
51
|
+
"summary",
|
|
52
|
+
"parent(issues(id))",
|
|
53
|
+
"customFields(name,value(name))",
|
|
54
|
+
]
|
|
55
|
+
params = {"fields": ",".join(_fields)}
|
|
49
56
|
issue = self._client.get(f"issues/{issue_id}", params=params).json()
|
|
50
57
|
issue["Type"] = self._get_issue_type_name(issue)
|
|
51
58
|
logger.debug(f"YouTrack Issue json {issue}")
|
|
@@ -214,3 +221,69 @@ class YoutrackHandler:
|
|
|
214
221
|
parent = issue["parent"]["issues"][0]
|
|
215
222
|
# recursively get parent issue's type
|
|
216
223
|
return self.get_issue(parent["id"])["Type"]
|
|
224
|
+
|
|
225
|
+
def get_issue_descendants(self, issue_id):
|
|
226
|
+
_fields = [
|
|
227
|
+
"resolved",
|
|
228
|
+
"subtasks(issues(id,idReadable,resolved,summary,customFields(name,value),subtasks(issues(id))))",
|
|
229
|
+
]
|
|
230
|
+
params = {"fields": ",".join(_fields)}
|
|
231
|
+
issue = self._client.get(f"issues/{issue_id}", params=params).json()
|
|
232
|
+
|
|
233
|
+
descendants = []
|
|
234
|
+
for child in issue.get("subtasks", {}).get("issues", []):
|
|
235
|
+
descendants.append(child)
|
|
236
|
+
if child.get("subtasks", {}).get("issues"):
|
|
237
|
+
descendants.extend(self.get_issue_descendants(child["id"]))
|
|
238
|
+
return descendants
|
|
239
|
+
|
|
240
|
+
def get_current_sprint(self, agile_board_id):
|
|
241
|
+
params = {
|
|
242
|
+
"fields": "id",
|
|
243
|
+
}
|
|
244
|
+
return self._client.get(
|
|
245
|
+
f"agiles/{agile_board_id}/sprints/current", params=params
|
|
246
|
+
).json()
|
|
247
|
+
|
|
248
|
+
def get_sprints(self, agile_board_id):
|
|
249
|
+
params = {
|
|
250
|
+
"fields": "id",
|
|
251
|
+
}
|
|
252
|
+
return self._client.get(
|
|
253
|
+
f"agiles/{agile_board_id}/sprints", params=params
|
|
254
|
+
).json()
|
|
255
|
+
|
|
256
|
+
def get_sprint_resolved_story_points(self, agile_board_id, sprint_id):
|
|
257
|
+
"""Get the sum of the story point estimates of all resolved issues of a sprint."""
|
|
258
|
+
params = {
|
|
259
|
+
"fields": "id,name,goal,issues(id,idReadable,summary,resolved,customFields(name,value))",
|
|
260
|
+
}
|
|
261
|
+
sprint = self._client.get(
|
|
262
|
+
f"agiles/{agile_board_id}/sprints/{sprint_id}", params=params
|
|
263
|
+
).json()
|
|
264
|
+
|
|
265
|
+
resolved_issues = [issue for issue in sprint["issues"] if issue["resolved"]]
|
|
266
|
+
|
|
267
|
+
total_story_points = 0
|
|
268
|
+
for issue in resolved_issues:
|
|
269
|
+
# Find the Story Points custom field
|
|
270
|
+
story_points_field = next(
|
|
271
|
+
(
|
|
272
|
+
field
|
|
273
|
+
for field in issue.get("customFields", [])
|
|
274
|
+
if field["name"] == "Story Points"
|
|
275
|
+
),
|
|
276
|
+
None,
|
|
277
|
+
)
|
|
278
|
+
if story_points_field and story_points_field.get("value"):
|
|
279
|
+
try:
|
|
280
|
+
story_points = int(story_points_field["value"])
|
|
281
|
+
total_story_points += story_points
|
|
282
|
+
except (ValueError, TypeError):
|
|
283
|
+
# Skip issues with invalid story points values
|
|
284
|
+
logger.debug(
|
|
285
|
+
f"Invalid story points value for issue {issue.get('idReadable', 'unknown')}: {story_points_field.get('value')}"
|
|
286
|
+
)
|
|
287
|
+
continue
|
|
288
|
+
|
|
289
|
+
return total_story_points
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: suite-py
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.46.0
|
|
4
4
|
Summary:
|
|
5
5
|
Author: larrywax, EugenioLaghi, michelangelomo
|
|
6
6
|
Author-email: devops@prima.it
|
|
@@ -28,7 +28,7 @@ Requires-Dist: pytest (>=7.0.0)
|
|
|
28
28
|
Requires-Dist: python-dateutil (>=2.8.2)
|
|
29
29
|
Requires-Dist: requests (>=2.26.0)
|
|
30
30
|
Requires-Dist: requests-toolbelt (>=0.9.1)
|
|
31
|
-
Requires-Dist: rich (==14.
|
|
31
|
+
Requires-Dist: rich (==14.1.0)
|
|
32
32
|
Requires-Dist: semver (>=3.0.4,<4.0.0)
|
|
33
33
|
Requires-Dist: termcolor (>=1.1.0)
|
|
34
34
|
Requires-Dist: truststore (>=0.7,<0.11) ; python_version >= "3.10"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
suite_py/__init__.py,sha256=REmi3D0X2G1ZWnYpKs8Ffm3NIj-Hw6dMuvz2b9NW344,142
|
|
2
|
-
suite_py/__version__.py,sha256=
|
|
3
|
-
suite_py/cli.py,sha256=
|
|
2
|
+
suite_py/__version__.py,sha256=y_irmWufF1id-FK0jAuz962BX7uXinVOrDlZ-WZGMts,49
|
|
3
|
+
suite_py/cli.py,sha256=hBbNXb9vVk8lSJXRrb1GctTp3EUjMYFWS9mn_HaNG9I,11155
|
|
4
4
|
suite_py/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
suite_py/commands/ask_review.py,sha256=yN__Ac-fiZBPShjRDhyCCQZGfVlQE16KozoJk4UtiNw,3788
|
|
6
6
|
suite_py/commands/bump.py,sha256=oFZU1hPfD11ujFC5G7wFyQOf2alY3xp2SO1h1ldjf3s,5406
|
|
@@ -8,6 +8,7 @@ suite_py/commands/check.py,sha256=jCX59g6DgTA55yD_75mgcqJ5zCjRwl_eIRGDeUFjUWY,33
|
|
|
8
8
|
suite_py/commands/common.py,sha256=aWCEvO3hqdheuMUmZcHuc9EGZPQTk7VkzkHJk283MxQ,566
|
|
9
9
|
suite_py/commands/context.py,sha256=6dssSqoABPb9gLmL3Y7W2iAGxrY_oma665X8zrSkNNQ,1079
|
|
10
10
|
suite_py/commands/create_branch.py,sha256=6sveTtOg_0lQl-MYizcnnyYyAunA_dXunQAxv7szllE,4577
|
|
11
|
+
suite_py/commands/estimate_cone.py,sha256=_RekBWzPlzInlZRpSIeKUVkx-A8Phx0IEYVouTbN7z4,3411
|
|
11
12
|
suite_py/commands/login.py,sha256=A59e1HsbN7Ocv2L_2H0Eb7MZK7AzLkLb72QxBthnIqU,258
|
|
12
13
|
suite_py/commands/merge_pr.py,sha256=fXIE8mT9MjvvpqE-uVdXGBVFGhn0eQzcBxNr-N8SyAY,5171
|
|
13
14
|
suite_py/commands/open_pr.py,sha256=e6IT6f8L_HKsOEtrGHZQ2HWrFwmvIgXGNCK_TU0WE9k,7009
|
|
@@ -29,7 +30,7 @@ suite_py/lib/handler/okta_handler.py,sha256=UiRcBDmFkMFi9H7Me1QaruC8yPI5fFbnLGzO
|
|
|
29
30
|
suite_py/lib/handler/pre_commit_handler.py,sha256=nwqVgC-KnUjn7NVIHZ0VmDdUfp6Q1ieFIth-1_U76Gw,3740
|
|
30
31
|
suite_py/lib/handler/prompt_utils.py,sha256=vgk1O7h-iYEAZv1sXtMh8xIgH1djI398rzxRIgZWZcg,2474
|
|
31
32
|
suite_py/lib/handler/version_handler.py,sha256=DXTx4yCAbFVC6CdMqPJ-LiN5YM-dT2zklG8POyKTP5A,6774
|
|
32
|
-
suite_py/lib/handler/youtrack_handler.py,sha256=
|
|
33
|
+
suite_py/lib/handler/youtrack_handler.py,sha256=_CwzeFhj7kMYb61CN8IYF0IE55Zrj6vZT38SUZLA5B8,10192
|
|
33
34
|
suite_py/lib/logger.py,sha256=aL870R69enNL9K8mQrMFgSAVUPXXgkvaVp6xTprCBWA,1029
|
|
34
35
|
suite_py/lib/metrics.py,sha256=urTBVzIc1Ys6OHPOO32fLPPRcQU45tzM3XMJ7mUl5dc,1629
|
|
35
36
|
suite_py/lib/oauth.py,sha256=tE3MgCnYhW6ZIbkyeUohFTOUvnBsrJXfHN8XsAVQNXk,5077
|
|
@@ -39,7 +40,7 @@ suite_py/lib/requests/session.py,sha256=P32H3cWnCWunu91WIj2iDM5U3HzaBglg60VN_C9J
|
|
|
39
40
|
suite_py/lib/symbol.py,sha256=z3QYBuNIwD3qQ3zF-cLOomIr_-C3bO_u5UIDAHMiyTo,60
|
|
40
41
|
suite_py/lib/tokens.py,sha256=4DbsHDFLIxs40t3mRw_ZyhmejZQ0Bht7iAL8dTCTQd4,5458
|
|
41
42
|
suite_py/templates/login.html,sha256=fJLls2SB84oZTSrxTdA5q1PqfvIHcCD4fhVWfyco7Ig,861
|
|
42
|
-
suite_py-1.
|
|
43
|
-
suite_py-1.
|
|
44
|
-
suite_py-1.
|
|
45
|
-
suite_py-1.
|
|
43
|
+
suite_py-1.46.0.dist-info/METADATA,sha256=xKqjzEcrChO20inY1mhWsY49b3tJVhvdE8HchWfwPJ4,1250
|
|
44
|
+
suite_py-1.46.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
45
|
+
suite_py-1.46.0.dist-info/entry_points.txt,sha256=dVKLC-9Infy-dHJT_MkK6LcDjOgBCJ8lfPkURJhBjxE,46
|
|
46
|
+
suite_py-1.46.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|