cycl 1.1.2__tar.gz → 1.2.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycl
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: CLI and Python SDK to help identify cross-stack import/export circular dependencies, for a given AWS account and region.
5
5
  License: MIT
6
6
  Project-URL: Repository, http://github.com/tcm5343/cycl
@@ -9,7 +9,7 @@ import networkx as nx
9
9
  from botocore.config import Config
10
10
  from botocore.session import Session
11
11
 
12
- from cycl.models.node_data import NodeData
12
+ from cycl.models import NodeData
13
13
  from cycl.utils.cdk import get_exports_from_assembly
14
14
 
15
15
  if TYPE_CHECKING:
@@ -43,7 +43,7 @@ def get_graph_data(
43
43
  exports = NodeData.get_all_exports(cfn_client=cfn_client)
44
44
  for export_name, importing_stacks in cdk_out_imports.items():
45
45
  if export_name not in exports:
46
- log.warning(
46
+ log.debug(
47
47
  'found an export (%s) which has not been deployed yet about to be imported stack(s): (%s)',
48
48
  export_name,
49
49
  importing_stacks,
@@ -59,6 +59,15 @@ def get_graph_data(
59
59
  return exports
60
60
 
61
61
 
62
+ def __add_node_data(graph: nx.MultiDiGraph, key: Hashable, data: NodeData) -> None:
63
+ if key not in graph:
64
+ graph.add_node(key, node_data={data})
65
+ return
66
+
67
+ node_data: set[NodeData] = graph.nodes[key].setdefault('node_data', set())
68
+ node_data.add(data)
69
+
70
+
62
71
  def build_graph( # noqa: PLR0913
63
72
  graph_data: dict[str, NodeData] | None = None,
64
73
  cdk_out_path: Path | None = None,
@@ -86,7 +95,7 @@ def build_graph( # noqa: PLR0913
86
95
  if export_key in nodes_to_ignore:
87
96
  continue
88
97
 
89
- dep_graph.add_node(export_key, node_data=export)
98
+ __add_node_data(dep_graph, export_key, export)
90
99
 
91
100
  for importing_stack in export.importing_stacks:
92
101
  importing_key = node_key_fn(importing_stack)
@@ -94,7 +103,7 @@ def build_graph( # noqa: PLR0913
94
103
  edge = (export_key, importing_key)
95
104
  if list(edge) not in edges_to_ignore:
96
105
  dep_graph.add_edge(*edge)
97
- dep_graph.add_node(importing_key, node_data=importing_stack)
106
+ __add_node_data(dep_graph, importing_key, importing_stack)
98
107
 
99
108
  if remove_selfloops:
100
109
  dep_graph.remove_edges_from(nx.selfloop_edges(dep_graph))
@@ -0,0 +1 @@
1
+ from .node_data import NodeData
@@ -6,6 +6,8 @@ from typing import TYPE_CHECKING
6
6
  import boto3
7
7
  from botocore.exceptions import ClientError
8
8
 
9
+ from cycl.utils.cfn import parse_name_from_id
10
+
9
11
  if TYPE_CHECKING:
10
12
  from mypy_boto3_cloudformation import CloudFormationClient
11
13
  from mypy_boto3_cloudformation.type_defs import ListExportsOutputTypeDef
@@ -14,6 +16,8 @@ log = getLogger(__name__)
14
16
 
15
17
 
16
18
  class NodeData:
19
+ """Data collected to be used in graph creation."""
20
+
17
21
  def __init__(
18
22
  self,
19
23
  stack_name: str,
@@ -53,7 +57,7 @@ class NodeData:
53
57
  """
54
58
  return {
55
59
  export['Name']: cls(
56
- stack_name=cls.parse_name_from_id(export['ExportingStackId']),
60
+ stack_name=parse_name_from_id(export['ExportingStackId']),
57
61
  stack_id=export['ExportingStackId'],
58
62
  export_name=export['Name'],
59
63
  export_value=export['Value'],
@@ -140,23 +144,3 @@ class NodeData:
140
144
  )
141
145
  log.warning(warning_msg)
142
146
  return self
143
-
144
- @staticmethod
145
- def parse_name_from_id(stack_id: str) -> str:
146
- """Extract the stack name from a given stack ID.
147
-
148
- Args:
149
- stack_id: The full stack ID, typically in the format
150
- 'arn:aws:cloudformation:region:account-id:stack/stack-name/guid'.
151
-
152
- Returns:
153
- The extracted stack name, or an empty string if parsing fails.
154
-
155
- Note:
156
- Logs a warning if the stack ID format is unexpected.
157
- """
158
- try:
159
- return stack_id.split('/')[1]
160
- except IndexError:
161
- log.warning('Unable to parse name from stack_id: %s', stack_id)
162
- return ''
@@ -0,0 +1,23 @@
1
+ from logging import getLogger
2
+
3
+ log = getLogger(__name__)
4
+
5
+
6
+ def parse_name_from_id(stack_id: str) -> str:
7
+ """Extract the stack name from a given stack ID.
8
+
9
+ Args:
10
+ stack_id: The full stack ID, typically in the format
11
+ 'arn:aws:cloudformation:region:account-id:stack/stack-name/guid'.
12
+
13
+ Returns:
14
+ The extracted stack name, or an empty string if parsing fails.
15
+
16
+ Note:
17
+ Logs a warning if the stack ID format is unexpected.
18
+ """
19
+ try:
20
+ return stack_id.split('/')[1]
21
+ except IndexError:
22
+ log.warning('Unable to parse stack_name from stack_id: %s', stack_id)
23
+ return ''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycl
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: CLI and Python SDK to help identify cross-stack import/export circular dependencies, for a given AWS account and region.
5
5
  License: MIT
6
6
  Project-URL: Repository, http://github.com/tcm5343/cycl
@@ -16,5 +16,6 @@ src/cycl/models/__init__.py
16
16
  src/cycl/models/node_data.py
17
17
  src/cycl/utils/__init__.py
18
18
  src/cycl/utils/cdk.py
19
+ src/cycl/utils/cfn.py
19
20
  src/cycl/utils/log_config.py
20
21
  src/cycl/utils/testing.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes