Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion TutorialMaker/TutorialMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ def onComplete():
def Generate(self, tutorialName):
modulePath = Lib.TutorialUtils.get_module_basepath("TutorialMaker")
annotationsPath = modulePath + f"/Outputs/Annotations/{tutorialName}/annotations.json"
currentTutorial = None
try:
currentTutorial = os.environ["TUTORIAL_CURRENT_SELFTEST"]
except e:
pass

os.environ["TUTORIAL_CURRENT_SELFTEST"] = tutorialName

if not os.path.exists(annotationsPath):
# In testing/CI mode, print warning instead of showing modal dialog
Expand All @@ -458,9 +465,18 @@ def Generate(self, tutorialName):
_("No Annotations Found")
)
return
_exception = None
try:
AnnotationPainter.TutorialPainter().GenerateHTMLfromAnnotatedTutorial(annotationsPath)
except Exception as error:
if (os.environ.get('CI') == 'true' or os.environ.get('GITHUB_ACTIONS') == 'true'):
raise error
else:
_exception = error

with slicer.util.tryWithErrorDisplay(_("Failed to generate tutorial")):
AnnotationPainter.TutorialPainter().GenerateHTMLfromAnnotatedTutorial(annotationsPath)
if _exception is not None:
raise _exception
outputPath = modulePath + "/Outputs/"

# Check if we're in testing/CI mode - check all possible indicators
Expand Down Expand Up @@ -492,6 +508,8 @@ def Generate(self, tutorialName):
# In testing/CI mode, just print the message
print(f"✅ Tutorial Generated: {tutorialName}")
print(f" Output path: {outputPath}")

os.environ["TUTORIAL_CURRENT_SELFTEST"] = currentTutorial
pass

def CreateNewTutorial(self):
Expand Down
Loading