buildzr 0.0.17__py3-none-any.whl → 0.0.19__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.
buildzr/__about__.py CHANGED
@@ -1 +1 @@
1
- VERSION = "0.0.17"
1
+ VERSION = "0.0.19"
buildzr/dsl/dsl.py CHANGED
@@ -129,16 +129,19 @@ class Workspace(DslWorkspaceElement):
129
129
 
130
130
  _current_workspace.reset(self._token)
131
131
 
132
- def _imply_relationships(
133
- self,
132
+ def _imply_relationships( self,
134
133
  ) -> None:
135
134
 
136
135
  """
137
136
  Process implied relationships:
138
137
  If we have relationship s >> do >> a.b, then create s >> do >> a.
139
138
  If we have relationship s.ss >> do >> a.b.c, then create s.ss >> do >> a.b and s.ss >> do >> a.
139
+ If we have relationship s.ss >> do >> a, then create s >> do >> a.
140
140
  And so on...
141
141
 
142
+ Relationships of `SoftwareSystemInstance`s and `ContainerInstance`s are
143
+ skipped.
144
+
142
145
  This process is idempotent, which means this can be called multiple times
143
146
  without duplicating similar relationships.
144
147
  """
@@ -149,12 +152,22 @@ class Workspace(DslWorkspaceElement):
149
152
  from buildzr.dsl.explorer import Explorer
150
153
 
151
154
  explorer = Explorer(self)
155
+ # Take a snapshot of relationships to avoid processing newly created ones
152
156
  relationships = list(explorer.walk_relationships())
153
157
  for relationship in relationships:
154
158
  source = relationship.source
155
159
  destination = relationship.destination
156
160
  destination_parent = destination.parent
157
161
 
162
+ if isinstance(source, (SoftwareSystemInstance, ContainerInstance)) or \
163
+ isinstance(destination, (SoftwareSystemInstance, ContainerInstance)):
164
+ continue
165
+
166
+ # Skip relationships that are already implied (have linkedRelationshipId)
167
+ if relationship.model.linkedRelationshipId is not None:
168
+ continue
169
+
170
+ # Handle case: s >> a.b => s >> a (destination is child)
158
171
  while destination_parent is not None and \
159
172
  isinstance(source, DslElement) and \
160
173
  not isinstance(source.model, buildzr.models.Workspace) and \
@@ -179,7 +192,38 @@ class Workspace(DslWorkspaceElement):
179
192
  technology=relationship.model.technology,
180
193
  )
181
194
  r.model.linkedRelationshipId = relationship.model.id
182
- destination_parent = destination_parent.parent
195
+ destination_parent = destination_parent.parent
196
+
197
+ # Handle inverse case: s.ss >> a => s >> a (source is child)
198
+ source_parent = source.parent
199
+ while source_parent is not None and \
200
+ isinstance(destination, DslElement) and \
201
+ not isinstance(destination.model, buildzr.models.Workspace) and \
202
+ not isinstance(source_parent.model, buildzr.models.Workspace) and \
203
+ not isinstance(source_parent, DslWorkspaceElement):
204
+
205
+ if source_parent is destination.parent:
206
+ break
207
+
208
+ rels = source_parent.model.relationships
209
+
210
+ # The parent source relationship might be empty
211
+ # (i.e., []).
212
+ if rels is not None:
213
+ already_exists = any(
214
+ r.destinationId == destination.model.id and
215
+ r.description == relationship.model.description and
216
+ r.technology == relationship.model.technology
217
+ for r in rels
218
+ )
219
+ if not already_exists:
220
+ r = source_parent.uses(
221
+ destination,
222
+ description=relationship.model.description,
223
+ technology=relationship.model.technology,
224
+ )
225
+ r.model.linkedRelationshipId = relationship.model.id
226
+ source_parent = source_parent.parent
183
227
 
184
228
  def person(self) -> TypedDynamicAttribute['Person']:
185
229
  return TypedDynamicAttribute['Person'](self._dynamic_attrs)
@@ -364,6 +408,7 @@ class SoftwareSystem(DslElementRelationOverrides[
364
408
  self.model.id = GenerateId.for_element()
365
409
  self.model.name = name
366
410
  self.model.description = description
411
+ self.model.relationships = []
367
412
  self.model.tags = ','.join(self._tags)
368
413
  self.model.properties = properties
369
414
 
@@ -832,6 +877,12 @@ class DeploymentEnvironment(DslDeploymentEnvironment):
832
877
  if not relationship.destinationId in other_softwares_ids:
833
878
  continue
834
879
 
880
+ if software.model.id not in software_instance_map:
881
+ continue
882
+
883
+ if relationship.destinationId not in software_instance_map:
884
+ continue
885
+
835
886
  this_software_instances = software_instance_map[software.model.id]
836
887
  other_software_instances = software_instance_map[relationship.destinationId]
837
888
 
@@ -900,6 +951,12 @@ class DeploymentEnvironment(DslDeploymentEnvironment):
900
951
  if not relationship.destinationId in other_containers_ids:
901
952
  continue
902
953
 
954
+ if container.model.id not in container_instance_map:
955
+ continue
956
+
957
+ if relationship.destinationId not in container_instance_map:
958
+ continue
959
+
903
960
  this_container_instances = container_instance_map[container.model.id]
904
961
  other_container_instances = container_instance_map[relationship.destinationId]
905
962
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: buildzr
3
- Version: 0.0.17
3
+ Version: 0.0.19
4
4
  Summary: Structurizr for the `buildzr`s 🧱⚒️
5
5
  Project-URL: homepage, https://github.com/amirulmenjeni/buildzr
6
6
  Project-URL: issues, https://github.com/amirulmenjeni/buildzr/issues
@@ -1,8 +1,8 @@
1
- buildzr/__about__.py,sha256=FuXai4m-tgRgZ8KBZ-0FvcOhuA5UBAazPvu_4YgO1kY,19
1
+ buildzr/__about__.py,sha256=aMHUW8D8Fq0eyBBQcpY6OmdN1KpA2z9MDEG8mxBR4uU,19
2
2
  buildzr/__init__.py,sha256=hY-cOdjBQcz0v2m8cBF1oEJFIbcR3sWI-xww--0RKSo,99
3
3
  buildzr/dsl/__init__.py,sha256=qJ41IXcabKUjvwMzgfUCFdmDnSBBK7VFADpoVdOYLKQ,538
4
4
  buildzr/dsl/color.py,sha256=at5lo3WgLEDCjrnbu37ra1p1TjzdB51sxeW7pBMC_7U,4019
5
- buildzr/dsl/dsl.py,sha256=l3eM3WtcBMcoroXgn2gKaMluFb4rQUrFSRx89kuGshc,83901
5
+ buildzr/dsl/dsl.py,sha256=LvZbv33z_ZDru2Otf6vFwQrdEAaeGm670R0cnyUqJk8,86512
6
6
  buildzr/dsl/explorer.py,sha256=m1nI0Rd0bXGj1uXDgTC4DJhc2FMma522IepPNvQF07E,1853
7
7
  buildzr/dsl/expression.py,sha256=TLSe-uGlHhNqMPQU_5IRLIP-ZGsQ_ts3DquBMcYlwBg,11777
8
8
  buildzr/dsl/relations.py,sha256=GBs5epr9uuExU_H6VcP4XY76iJPQ__rz_d8tZlhhWQ4,11891
@@ -18,7 +18,7 @@ buildzr/models/models.py,sha256=NJOFYiRQ2i_1gP2ajPNpEfVLAz-1iCqqt1gPOHDPIks,4258
18
18
  buildzr/sinks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  buildzr/sinks/interfaces.py,sha256=LOZekP4WNjomD5J5f3FnZTwGj0aXMr6RbrvyFV5zn0E,383
20
20
  buildzr/sinks/json_sink.py,sha256=w_16ulQl2s-J-Yokp6GvDhAhuqN8XggXyEHCUNETLu4,865
21
- buildzr-0.0.17.dist-info/METADATA,sha256=hHN9k8oQtuVu0hKASmJpvvoXl7GP1ZbfDdquEWbWlcU,6596
22
- buildzr-0.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- buildzr-0.0.17.dist-info/licenses/LICENSE.md,sha256=e8e6W6tL4MbBY-c-gXMgDbaMf_BnaQDQv4Yoy42b-CI,1070
24
- buildzr-0.0.17.dist-info/RECORD,,
21
+ buildzr-0.0.19.dist-info/METADATA,sha256=7Ty1qRdPRm-JhLe8gyqR-lRF2rJPDxiRh3b3J6eRpYU,6596
22
+ buildzr-0.0.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ buildzr-0.0.19.dist-info/licenses/LICENSE.md,sha256=e8e6W6tL4MbBY-c-gXMgDbaMf_BnaQDQv4Yoy42b-CI,1070
24
+ buildzr-0.0.19.dist-info/RECORD,,