Skip to content

Commit

Permalink
fix tests for recipes without a fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Jun 26, 2024
1 parent 9510f40 commit e14faa1
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ def get_sr_from_query_params(
), "invalid published run: without a saved run"
sr = pr.saved_run
else:
sr = cls.recipe_doc_sr(create=True)
sr = cls.recipe_doc_sr()
return sr
except (SavedRun.DoesNotExist, PublishedRun.DoesNotExist):
raise HTTPException(status_code=404)
Expand All @@ -1124,20 +1124,24 @@ def get_or_create_root_published_run(cls) -> PublishedRun:
published_run, _ = PublishedRun.objects.get_or_create(
workflow=cls.workflow,
published_run_id="",
defaults={
"saved_run": lambda: cls.run_doc_sr(run_id="", uid="", create=True),
"created_by": None,
"last_edited_by": None,
"title": cls.title,
"notes": cls().preview_description(state=cls.sane_defaults),
"visibility": PublishedRunVisibility(PublishedRunVisibility.PUBLIC),
"is_approved_example": True,
},
defaults=dict(
saved_run=lambda: SavedRun.objects.get_or_create(
example_id="", workflow=cls.workflow
)[0],
created_by=None,
last_edited_by=None,
title=cls.title,
notes=cls().preview_description(state=cls.sane_defaults),
visibility=lambda: PublishedRunVisibility(
PublishedRunVisibility.PUBLIC
),
is_approved_example=True,
),
)
return published_run

@classmethod
def recipe_doc_sr(cls, create: bool = False) -> SavedRun:
def recipe_doc_sr(cls, create: bool = True) -> SavedRun:
if create:
return cls.get_or_create_root_published_run().saved_run
else:
Expand Down

0 comments on commit e14faa1

Please sign in to comment.