Skip to content

Commit

Permalink
testing some output
Browse files Browse the repository at this point in the history
  • Loading branch information
samberger committed Mar 13, 2024
1 parent eeb4cc4 commit 64aa71d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function_inputs.json
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

.idea/*

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
Expand Down
3 changes: 3 additions & 0 deletions flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

def flatten_base(base: Base) -> Iterable[Base]:
"""Take a base and flatten it to an iterable of bases."""

if hasattr(base, "elements"):
print("flatten: base has " + str(len(elements)) + " elements")
for element in base["elements"]:
yield from flatten_base(element)

yield base
9 changes: 9 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def automate_function(
It also has conveniece methods attach result data to the Speckle model.
function_inputs: An instance object matching the defined schema.
"""

print("automate_function(): started")

# the context provides a conveniet way, to receive the triggering version
version_root_object = automate_context.receive_version()

Expand All @@ -55,7 +58,12 @@ def automate_function(
]
count = len(objects_with_forbidden_speckle_type)

print("automate_function(): found " + str(len(count)) + " elements of forbidden type: " + function_inputs.forbidden_speckle_type)

if count > 0:

print("automate_function(): count = " + str(len(count)) + " > 0")

# this is how a run is marked with a failure cause
automate_context.attach_error_to_objects(
category="Forbidden speckle_type"
Expand All @@ -75,6 +83,7 @@ def automate_function(
automate_context.set_context_view()

else:
print("automate_function(): count = " + str(len(count)) + "")
automate_context.mark_run_success("No forbidden types found.")

# if the function generates file results, this is how it can be
Expand Down

0 comments on commit 64aa71d

Please sign in to comment.