Skip to content

serverless: add support for pptx export #353

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

Merged
merged 48 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7a2dd14
Update test_template.py
viseshrp Jul 14, 2025
4ee6ed9
Merge branch 'main' into vrajendr/pptx-sls
viseshrp Jul 15, 2025
6e7865d
serverless: add support for pptx export
viseshrp Jul 15, 2025
caa15bf
Update instantiation.rst
viseshrp Jul 15, 2025
e77ff65
fix null pointer in load_templates()
viseshrp Jul 16, 2025
652f0ef
fix style
viseshrp Jul 16, 2025
64e05db
Update uv.lock
viseshrp Jul 16, 2025
7b887b0
fix check in render_report_as_pptx
viseshrp Jul 16, 2025
e665762
Update pyproject.toml
viseshrp Jul 16, 2025
34c4040
downgrade python-pptx
viseshrp Jul 16, 2025
097f731
Update templates.rst
viseshrp Jul 16, 2025
1de17e0
Update templates.rst
viseshrp Jul 16, 2025
7ae4bad
refactor tests
viseshrp Jul 16, 2025
e39ca7f
Update templates.rst
viseshrp Jul 16, 2025
73dd979
add tests for ADR.render_report_as_pptx
viseshrp Jul 16, 2025
19b0b11
Update codecov.yml
viseshrp Jul 16, 2025
f69c387
Update test_adr.py
viseshrp Jul 16, 2025
ebbd3d4
Update codecov.yml
viseshrp Jul 17, 2025
1627088
Update input.pptx
viseshrp Jul 17, 2025
8c36a26
add test_render_report_as_pptx_integration
viseshrp Jul 17, 2025
15786ca
improve integration test
viseshrp Jul 17, 2025
82a9b80
Merge branch 'main' into vrajendr/pptx-sls
viseshrp Jul 17, 2025
f948393
Update pyproject.toml
viseshrp Jul 17, 2025
cf6d09e
Update uv.lock
viseshrp Jul 17, 2025
d530592
fix docs
viseshrp Jul 18, 2025
e35c389
update integration tests
viseshrp Jul 21, 2025
411bfae
Merge branch 'main' into vrajendr/pptx-sls
viseshrp Jul 21, 2025
b8d6e88
Update pyproject.toml
viseshrp Jul 21, 2025
7892f69
Delete doc/source/sg_execution_times.rst
viseshrp Jul 21, 2025
0109bbf
Update test_adr.py
viseshrp Jul 21, 2025
e2c3d60
Update uv.lock
viseshrp Jul 21, 2025
3db327a
Update test_adr.py
viseshrp Jul 21, 2025
5ca123e
Update test_adr.py
viseshrp Jul 21, 2025
ba0c7bc
remove HTML item for now
viseshrp Jul 21, 2025
65a1ea2
Update test_adr.py
viseshrp Jul 21, 2025
88d1af2
Update test_adr.py
viseshrp Jul 21, 2025
2de9240
Update test_adr.py
viseshrp Jul 21, 2025
635ca60
update tests
viseshrp Jul 21, 2025
ce22e3d
fix tests
viseshrp Jul 22, 2025
967b769
Update test_adr.py
viseshrp Jul 22, 2025
8e8bc9b
Update test_adr.py
viseshrp Jul 22, 2025
24293a0
Update test_adr.py
viseshrp Jul 22, 2025
e5320ba
Update test_adr.py
viseshrp Jul 22, 2025
ae6da77
Update test_adr.py
viseshrp Jul 22, 2025
60a7b9d
Update test_adr.py
viseshrp Jul 22, 2025
1a6f90f
Update test_adr.py
viseshrp Jul 22, 2025
ef0f8c9
update tests
viseshrp Jul 22, 2025
c0b6001
Update Makefile
viseshrp Jul 22, 2025
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
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
coverage:
precision: 2
round: down
range: 80...90 # <80→red, 80–90→yellow, ≥90→green
range: "70...100"

status:
patch: off
Expand Down
2 changes: 1 addition & 1 deletion doc/source/serverless/caveats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Example: Threading with Serverless ADR
t.join()

Serverless ADR Usage Within Django Apps
--------------------------------------
---------------------------------------

- Serverless ADR internally configures Django settings and environment variables at the
process level during ``ADR.setup()``.
Expand Down
1 change: 1 addition & 0 deletions doc/source/serverless/instantiation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Useful for testing and ephemeral workflows where persistence is not needed.
in_memory=True,
)
adr.setup()
adr.close() # Call close() to clean up resources - optional but recommended

Note:

Expand Down
6 changes: 3 additions & 3 deletions doc/source/serverless/media_and_static.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Media and Static Files
=====================
======================

Serverless ADR manages two key asset categories essential for rich report presentation:

Expand All @@ -24,7 +24,7 @@ Media files complement your report Items and can include:
They are stored separately on disk in a **media directory** configured during ADR setup. Items reference media files by unique GUID-based filenames to avoid collisions and enable retrieval.

Static Files
~~~~~~~~~~~
~~~~~~~~~~~~

Static files provide the frontend styling and interactivity needed for report visualization. They include:

Expand Down Expand Up @@ -101,7 +101,7 @@ Example: Creating and saving an Image Item with a file
)

Working with Media Files Directly
--------------------------------
---------------------------------

You can access media file paths from Items:

Expand Down
75 changes: 72 additions & 3 deletions doc/source/serverless/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ You can use the following methods on a template instance to interact with proper
template.add_property({"column_count": 2})

Direct Attribute Access
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

Alternatively, some common properties can also be accessed or set using standard attribute
syntax on the template instance. For example:
Expand Down Expand Up @@ -286,7 +286,7 @@ Example: Creating a Nested Template Structure
results_panel.save()

Rendering Templates
------------------
-------------------

Templates can render themselves into complete HTML content using the ``render()`` method.

Expand All @@ -304,7 +304,6 @@ data for rendering, such as user-defined variables or configuration settings.

Rendering context supports options like:

- ``plotly`` flag to enable interactive plots
- Page dimensions and DPI for layout calculations
- Date and time formatting

Expand All @@ -313,6 +312,69 @@ Rendering context supports options like:
- If you would like more information on the error, set the ``debug`` flag to ``True`` when instantiating
the ``ADR`` class.

Rendering via the ADR Entry Point
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ADR singleton class provides convenient methods to render templates by name or other filters,
abstracting the fetching and rendering process:

.. code-block:: python

from ansys.dynamicreporting.core.serverless import ADR

adr = ADR.get_instance()

# Render an HTML report by name with optional context and item filtering
html_content = adr.render_report(
name="Serverless Simulation Report",
context={"key": "value"},
item_filter="A|i_tags|cont|project=wing_sim;",
)
with open("report.html", "w", encoding="utf-8") as f:
f.write(html_content)

The ``render_report()`` method:

- Requires at least one keyword argument to identify the template (e.g., ``name``, ``guid``).
- Passes the ``context`` and ``item_filter`` to the template's ``render()`` method.
- Raises ``ADRException`` on failure with descriptive error messages.

Rendering to PPTX
-----------------

You can render a PowerPoint (.pptx) file from templates of type ``PPTXLayout`` using either the template’s
``render_pptx()`` method or through the ADR singleton’s ``render_report_as_pptx()`` helper.

Example using the template method:

.. code-block:: python

pptx_bytes = pptx_template.render_pptx(
context={"key": "value"}, item_filter="A|i_tags|cont|project=wing_sim;"
)
with open("report.pptx", "wb") as f:
f.write(pptx_bytes)

Example using the ADR entrypoint:

.. code-block:: python

pptx_bytes = adr.render_report_as_pptx(
name="Serverless Simulation Report",
context={"key": "value"},
item_filter="A|i_tags|cont|project=wing_sim;",
)
with open("report.pptx", "wb") as f:
f.write(pptx_bytes)

Notes on ``render_report_as_pptx()`` method:

- The template identified by the filter (e.g., ``name``) must be of type ``PPTXLayout``.
- Raises an ``ADRException`` if the template is not found or not of the required type.
- Returns raw bytes of the generated PPTX presentation.
- Passes ``context`` and ``item_filter`` to the template’s ``render_pptx()`` method.
- Exceptions during rendering are wrapped and raised as ``ADRException``.

Lifecycle Notes
---------------

Expand All @@ -339,3 +401,10 @@ Summary
Templates are the backbone of report structure in Serverless ADR. They let you create
rich, dynamic, and highly customizable reports by defining layouts and generators,
setting filters and parameters, and nesting templates to build complex hierarchical reports.

Rendering can be done directly via template instances or conveniently through the ADR singleton instance.

- Use ``template.render()`` for HTML output.
- Use ``template.render_pptx()`` or ``adr.render_report_as_pptx()`` for PPTX output.
- Both rendering paths support passing context and filtering items if applicable.
- Handle exceptions raised as ``ADRException`` to debug issues.
Loading