Skip to content

Commit

Permalink
fix setting session, dataset via create_item (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
viseshrp authored Dec 5, 2024
1 parent 7de1a03 commit 8dd9805
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/ansys/dynamicreporting/core/serverless/adr.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ def session_guid(self) -> uuid.UUID:
def create_item(self, item_type: Type[Item], **kwargs: Any) -> Item:
if not issubclass(item_type, Item):
raise TypeError(f"{item_type} is not valid")
return item_type.create(session=self._session, dataset=self._dataset, **kwargs)
return item_type.create(
session=kwargs.pop("session", self._session),
dataset=kwargs.pop("dataset", self._dataset),
**kwargs,
)

def create_template(self, template_type: Type[Template], **kwargs: Any) -> Template:
if not issubclass(template_type, Template):
Expand Down Expand Up @@ -362,8 +366,8 @@ def query(
raise TypeError(f"{query_type} is not valid")
return query_type.find(query=query, **kwargs)

@staticmethod
def create_objects(
self,
objects: Union[list, ObjectSet],
**kwargs: Any,
) -> int:
Expand Down Expand Up @@ -392,6 +396,7 @@ def _copy_template(self, template: Template, **kwargs) -> Template:
out_template = copy.deepcopy(template)
if out_template.parent is not None:
parent = out_template.parent
# parents are always copied first, so they should exist
out_template.parent = Template.get(
guid=parent.guid, using=kwargs.get("using", "default")
)
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/dynamicreporting/core/serverless/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ def save(self, **kwargs):
raise Template.NotSaved(
extra_detail="Failed to save template because its parent is not saved"
)
children_order = []
for child in self.children:
if not child._saved:
raise Template.NotSaved(
extra_detail="Failed to save template because its children are not saved"
)
self._children_order = ",".join([str(child.guid) for child in self.children])
children_order.append(str(child.guid))
self._children_order = ",".join(children_order)
self._master = self.parent is None
# set properties
prop_dict = {}
Expand Down

0 comments on commit 8dd9805

Please sign in to comment.