buildzr 0.0.18__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.18"
1
+ VERSION = "0.0.19"
buildzr/dsl/dsl.py CHANGED
@@ -129,14 +129,14 @@ 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
142
  Relationships of `SoftwareSystemInstance`s and `ContainerInstance`s are
@@ -152,6 +152,7 @@ class Workspace(DslWorkspaceElement):
152
152
  from buildzr.dsl.explorer import Explorer
153
153
 
154
154
  explorer = Explorer(self)
155
+ # Take a snapshot of relationships to avoid processing newly created ones
155
156
  relationships = list(explorer.walk_relationships())
156
157
  for relationship in relationships:
157
158
  source = relationship.source
@@ -162,6 +163,11 @@ class Workspace(DslWorkspaceElement):
162
163
  isinstance(destination, (SoftwareSystemInstance, ContainerInstance)):
163
164
  continue
164
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)
165
171
  while destination_parent is not None and \
166
172
  isinstance(source, DslElement) and \
167
173
  not isinstance(source.model, buildzr.models.Workspace) and \
@@ -186,7 +192,38 @@ class Workspace(DslWorkspaceElement):
186
192
  technology=relationship.model.technology,
187
193
  )
188
194
  r.model.linkedRelationshipId = relationship.model.id
189
- 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
190
227
 
191
228
  def person(self) -> TypedDynamicAttribute['Person']:
192
229
  return TypedDynamicAttribute['Person'](self._dynamic_attrs)
@@ -371,6 +408,7 @@ class SoftwareSystem(DslElementRelationOverrides[
371
408
  self.model.id = GenerateId.for_element()
372
409
  self.model.name = name
373
410
  self.model.description = description
411
+ self.model.relationships = []
374
412
  self.model.tags = ','.join(self._tags)
375
413
  self.model.properties = properties
376
414
 
@@ -839,6 +877,12 @@ class DeploymentEnvironment(DslDeploymentEnvironment):
839
877
  if not relationship.destinationId in other_softwares_ids:
840
878
  continue
841
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
+
842
886
  this_software_instances = software_instance_map[software.model.id]
843
887
  other_software_instances = software_instance_map[relationship.destinationId]
844
888
 
@@ -907,6 +951,12 @@ class DeploymentEnvironment(DslDeploymentEnvironment):
907
951
  if not relationship.destinationId in other_containers_ids:
908
952
  continue
909
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
+
910
960
  this_container_instances = container_instance_map[container.model.id]
911
961
  other_container_instances = container_instance_map[relationship.destinationId]
912
962
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: buildzr
3
- Version: 0.0.18
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=1LKzsaMbuDHBcCQ6ItSCPh_aBbnriHkKXEDMLVVsZJQ,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=Z7dr0RLGMY5XKMtBTZJ9Kj1m6CAuA3TTTzLnpxR2SsE,84194
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.18.dist-info/METADATA,sha256=naP5ylRsLZTmqIQkQay09BL7PKo8t_Cns3WzFJCTdhE,6596
22
- buildzr-0.0.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- buildzr-0.0.18.dist-info/licenses/LICENSE.md,sha256=e8e6W6tL4MbBY-c-gXMgDbaMf_BnaQDQv4Yoy42b-CI,1070
24
- buildzr-0.0.18.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,,