Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several fixes for serverless APIs #198

Merged
merged 73 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
1895719
add missing dependencies for serverless
viseshrp Oct 9, 2024
aaa3e9a
reset flag before save
viseshrp Oct 9, 2024
51f72c5
fix some type hints
viseshrp Oct 9, 2024
d3abc60
fix formatting
viseshrp Oct 9, 2024
597aac5
Delete top.html
viseshrp Oct 9, 2024
77566b1
Delete test_serverless.py
viseshrp Oct 10, 2024
598a75f
formatting
viseshrp Oct 10, 2024
98d3d0f
disable docs-style
viseshrp Oct 10, 2024
cfe846c
handle database errors with save()
viseshrp Oct 11, 2024
ba3c552
make sure to close file handles properly
viseshrp Oct 18, 2024
79c1d7f
pass generic kwargs to find()
viseshrp Oct 18, 2024
706248d
Merge branch 'main' into feat/serverless
viseshrp Oct 21, 2024
73be3d6
use the file handle properly for file payload saves
viseshrp Oct 21, 2024
9714097
add create_objects and copy_objects stubs
viseshrp Oct 21, 2024
886f03f
Merge branch 'main' into feat/serverless
viseshrp Oct 21, 2024
8a2f941
migrate multiple databases at once
viseshrp Oct 23, 2024
86ea319
add as_dict and get_or_create
viseshrp Oct 23, 2024
efbf622
fix as_dict
viseshrp Oct 23, 2024
b3988cb
fix Session attrs
viseshrp Oct 23, 2024
c061a07
allow setting guid
viseshrp Oct 23, 2024
dedf8ee
don't reset the orm object before save
viseshrp Oct 25, 2024
0b8869b
add a few helper methods
viseshrp Oct 26, 2024
82c80f4
fix some exceptions in copy_objects
viseshrp Oct 27, 2024
ff96237
Merge branch 'main' into feat/serverless
viseshrp Oct 28, 2024
447ca14
fix style
viseshrp Oct 28, 2024
2367c74
add a reinit method for integrity
viseshrp Nov 1, 2024
f1d275e
fix save in file payloads
viseshrp Nov 1, 2024
484c0c1
fix ObjectSet.delete
viseshrp Nov 1, 2024
a8b4dc6
fix copying of items
viseshrp Nov 1, 2024
b5a28dd
Update .gitignore
viseshrp Nov 6, 2024
cff2ce7
Merge branch 'main' into feat/serverless
viseshrp Nov 12, 2024
e49ae63
fix imports
viseshrp Nov 12, 2024
03d0f50
revert copy_objects
viseshrp Nov 12, 2024
860f336
fix _get_db_dir
viseshrp Nov 12, 2024
1d0ae29
add backward compat support for report_type
viseshrp Nov 12, 2024
98fd218
Merge branch 'main' into feat/serverless
viseshrp Nov 12, 2024
ffeb3f1
fix style
viseshrp Nov 12, 2024
84e8ba2
use str for guid type instead of UUID
viseshrp Nov 13, 2024
c9b75b6
Merge branch 'main' into feat/serverless
viseshrp Nov 13, 2024
717a733
Update base.py
viseshrp Nov 13, 2024
206f078
add casting for some values
viseshrp Nov 14, 2024
5c5180c
create users/groups only for the default database
viseshrp Nov 18, 2024
a121e06
Merge branch 'main' into feat/serverless
viseshrp Nov 18, 2024
895454a
add missing generators
viseshrp Nov 19, 2024
83fe18e
Merge branch 'main' into feat/serverless
viseshrp Nov 19, 2024
b2e51c9
make unique_id optional in rebuild_3d_geometry
viseshrp Nov 21, 2024
c75a6fc
improve handling of images + support for deep imgs
viseshrp Nov 21, 2024
c4dbabf
improve ADR.setup()
viseshrp Nov 21, 2024
69db1ee
Merge branch 'main' into feat/serverless
viseshrp Nov 21, 2024
4f26c1b
remove double content set
viseshrp Nov 21, 2024
f136c56
bump ansys version & change install path error handling
viseshrp Nov 22, 2024
9617d97
Merge branch 'main' into feat/serverless
viseshrp Nov 22, 2024
d809fe5
fix style
viseshrp Nov 22, 2024
04e766b
fix ansys path exception
viseshrp Nov 22, 2024
96c9066
change nightly to run before ADR builds
viseshrp Nov 22, 2024
f925d3e
fix import
viseshrp Nov 22, 2024
90f1434
rebuild 3d only if necessary
viseshrp Nov 24, 2024
30d3a7c
set saved as false during reinit
viseshrp Nov 24, 2024
e46c4f1
fix copy_objects with support for items only
viseshrp Nov 24, 2024
cafe1fa
Merge branch 'main' into feat/serverless
viseshrp Nov 24, 2024
33a295a
fix some Template attributes
viseshrp Dec 2, 2024
44e0797
fix parent-child load from_db
viseshrp Dec 4, 2024
9df05e1
fix copy_objects support for templates
viseshrp Dec 4, 2024
36ee3f8
Merge branch 'main' into feat/serverless
viseshrp Dec 4, 2024
563d993
refactor children_order save
viseshrp Dec 4, 2024
2ac4413
Merge branch 'main' into feat/serverless
viseshrp Dec 4, 2024
5754d7d
fix setting session, dataset via create_item
viseshrp Dec 5, 2024
4340654
use item_filter for template render
viseshrp Dec 5, 2024
f5cd70c
specify r_type in get_list_reports as kwarg
viseshrp Dec 6, 2024
7fe4eb8
handle empty db dirs
viseshrp Dec 6, 2024
af724af
improve copy_objects error message
viseshrp Dec 6, 2024
8f76b76
Merge branch 'main' into feat/serverless
viseshrp Dec 6, 2024
eb4a1a0
fix error message
viseshrp Dec 6, 2024
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
23 changes: 19 additions & 4 deletions src/ansys/dynamicreporting/core/serverless/adr.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def __init__(
# And make a target file (.nexdb) for auto launching of the report viewer...
with open(self._db_directory / "view_report.nexdb", "w") as f:
f.write(secret_key)
else:
# check if there is a sqlite db in the directory
db_files = list(self._db_directory.glob("*.sqlite3"))
if not db_files:
raise InvalidPath(
extra_detail="No sqlite3 database found in the directory. Remove the existing directory if"
" you would like to create a new database."
)

os.environ["CEI_NEXUS_LOCAL_DB_DIR"] = db_directory
elif "CEI_NEXUS_LOCAL_DB_DIR" in os.environ:
Expand Down Expand Up @@ -344,14 +352,21 @@ def get_list_reports(self, r_type: str = "name") -> Union[ObjectSet, list]:
if r_type not in supported_types:
raise ADRException(f"r_type must be one of {supported_types}")
if r_type == "name":
return self.get_reports([r_type], flat=True)
return self.get_reports(
fields=[
r_type,
],
flat=True,
)
else:
return self.get_reports()

def render_report(self, context: Optional[dict] = None, query: str = "", **kwargs: Any) -> str:
def render_report(
self, context: Optional[dict] = None, item_filter: str = "", **kwargs: Any
) -> str:
try:
return Template.get(**kwargs).render(
request=self._request, context=context, query=query
request=self._request, context=context, item_filter=item_filter
)
except Exception as e:
raise e
Expand Down Expand Up @@ -433,7 +448,7 @@ def copy_objects(

if target_database not in self._databases or source_database not in self._databases:
raise ADRException(
f"'{source_database}' and '{target_database}' must be configured first"
f"'{source_database}' and '{target_database}' must be configured first using the 'databases' option."
)

objects = self.query(object_type, query=query)
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dynamicreporting/core/serverless/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def add_property(self, new_props: dict):
params["properties"] = curr_props | new_props
self.params = json.dumps(params)

def render(self, context=None, request=None, query="") -> str:
def render(self, context=None, request=None, item_filter="") -> str:
if context is None:
context = {}
ctx = {**context, "request": request, "ansys_version": None}
Expand All @@ -214,7 +214,7 @@ def render(self, context=None, request=None, query="") -> str:

template_obj = self._orm_instance
engine = template_obj.get_engine()
items = Item.find(query=query)
items = Item.find(query=item_filter)
# properties that can change during iteration need to go on the class as well as globals
TemplateEngine.set_global_context({"page_number": 1, "root_template": template_obj})
TemplateEngine.start_toc_session()
Expand Down
Loading