Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.vscode
.DS_Store
.ipynb_checkpoints
.virtual_documents
*.html
__pycache__

Expand All @@ -15,5 +16,9 @@ up_template.egg-info/*
dockers/*/Dockerfile
.env

# Ignore data and outputs on repo
data
output

# Keep the HTML resources with the repo
!resources/*.html
77 changes: 55 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,56 @@ The foundation of all tools in this package is the [NetlOlca](https://doi.org/10


## Jupyter Notebook Unit Process Template
One of the main use cases for this tool is a new template based on Jupyter Notebook for reporting LCA unit processes.
The unit process template is a markdown file, organized by headers, to capture the essential information that goes into the creation of a life cycle unit process.
Capturing key metadata is critical for reproducibility of unit processes and for transparency to enable its application.

The new template is provided at the top-level of this repository (up_template.ipynb).
Two Python classes were developed to support the generation of this report:

![](img/package_uml.png)
1. NetlOlcaReport (up_template/NetlOlcaReport.py)
2. Interface (up_template/Interface.py)

Two additional classes were developed to support this interactive report generator:
The NetlOlcaReport class provides the methods for converting openLCA entity data into usable data frames and summaries and writing them into markdown format that can be converted into other reportable formats (e.g., HTML, Microsoft Word, and PDF).
The file format conversion depends on a user's local installation of [pandoc](https://pandoc.org/), a free and open-source tool for converting between different markup formats.

1. NetlOlcaReport (netlolca/NetlOlcaReport.py)
2. Interface (netlolca/Interface.py)
To create a blank template in markdown:

The NetlOlcaReport class provides intermediate methods for converting openLCA entity data into usable data frames and generating a summary of the results into a markdown format that can be converted into other reportable formats (e.g., HTML, Microsoft Word, and PDF).
The file format conversion depends on a user's local installation of [pandoc](https://pandoc.org/), a free and open-source tool for converting between different markup formats.
```python
>>> from netlolca import NetlOlca
>>> from up_template import NetlOlcaReport
>>> r = NetlOlcaReport(NetlOlca())
>>> r.save_markdown(blank=True)
```

You may edit this markdown file before rendering to HTML.
If you rename the file, be sure to update the reference name in the Python class.

```python
>>> r.reference_name = "new_report" # don't include the file extension
```

To generate the HTML version of the report, run the conversion method (PDF and Microsoft Word formats are also available).

```python
>>> r.convert_to_html() # requires pandoc install
>>> r.convert_to_pdf() # requires additional LaTeX install
>>> r.convert_to_word()
```

Automated methods are available in the NetlOlcaReport class, which attempt to read and extract metadata from an openLCA database and map it to the report template.
Similar to above, the steps to connect the NetlOlcaReport class to an openLCA database are as follows:

```python
>>> n = NetlOlca()
>>> n.connect() # establish connection via IPC service (default port 8080)
>>> n.read() # read database UUIDs
>>> r = NetlOlcaReport(n)
>>> ps_uuid = r.product_systems[0] # Get UUID of lone Product System
>>> r.fetch_data(ps_uuid) # Scrape database for metadata
>>> r.save_to_html() # create MD and HTML report files
```

The recommended app for running the UP Template is [JupyterLab](https://jupyter.org/), the latest web-based interactive development environment for computational notebooks.
The Interface.py is an experimental class that guides users through metadata review and gap-filling.
This is best accommodated through [JupyterLab](https://jupyter.org/), the latest web-based interactive development environment for computational notebooks.
JupyterLab may be installed using Python's `pip` or conda's `install` commands.
To start Jupyter Lab, run the following command (after installing) in the parent folder where your up_template.ipynb is located:

Expand All @@ -37,11 +72,12 @@ This should start the Jupyter notebook server and automatically launch the landi
up-template/
├── calculations/ <- store for auxiliary Excel workbooks to document
│ │ calculations in the UP template
│ └── calculation_template.xlsx <-- template for calculations
│ └── calculation_template.xlsx <- template for calculations
├── data/ <- empty folder for data files (e.g., JSON-LD)
├── (data/) <- folder for data files (e.g., JSON-LD)
├── dockers/ (for getting things to run in Docker)
│ ├── USERGUIDE.md <- Docker instructions
│ ├── gdt_server/
│ │ ├── README.md
│ │ ├── build.bat
Expand All @@ -56,6 +92,7 @@ This should start the Jupyter notebook server and automatically launch the landi
│ ├── build.sh
│ ├── get-docker.bat
│ ├── get-docker.sh
│ ├── requirements.txt
│ ├── run.bat
│ └── run.sh
Expand All @@ -65,25 +102,21 @@ This should start the Jupyter notebook server and automatically launch the landi
│ └── Makefile <- source files to documentation (e.g., html)
├── img/ <- image resources for notebooks and README
│ ├── banner.png (293 KB)
│ ├── boundary_diagram.png (205 KB)
│ ├── logo_doe-netl_white_1000x176.png (30 KB)
│ ├── netl_logo_100x52.png (14 KB)
│ ├── netl_logo_1153x599.png (26 KB)
│ ├── netl_logo2.svg (2 KB)
│ ├── netl_logo2_320x251.png (13 KB)
│ ├── ipynb-token.png (92 KB)
│ └── package_uml.png (281 KB)
├── (output/) <- Created when running UP Template to store the
│ generated reports (e.g., .md, .html, .docx, .pdf)
├── resources/
│ ├── after_body.html
│ ├── banner.png <- header in up_template.ipynb
│ ├── before_body.html
│ ├── banner.png
│ ├── netl_logo_100x52.png
│ ├── logo_doe-netl_white_1000x176.png
│ ├── (other logo files?)
│ ├── boundary_diagram.png
│ ├── logo_doe-netl_white_1000x176.png <- footer in template.docx
│ ├── netl_logo_100x52.png <- header in template.docx
│ ├── netl_logo_1153x599.png <- header in before_body.html
│ ├── styles.css
│ └── template.docx
├── up_template/ <- Source code for this package.
Expand Down
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "up_template"
version = "4.5.0"
description = "The NETL Unit Process Template and Report Generator"
readme = "README.md"
authors = [
{ name = "Tyler W. Davis" },
{ name = "Priyadarshini" },
{ name = "Joseph Chou" },
{ name = "Matt Jamieson", email = "matthew.jamieson@netl.doe.gov" }
]
license = "CC0-1.0"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"netlolca @ git+https://github.com/NETL-RIC/netlolca",
"openpyxl",
"pandas",
"sympy",
"tabulate",
"jupyterlab",
]

[project.urls]
Homepage = "https://github.com/NETL-RIC/up_template"

[tool.setuptools]
packages = ["up_template"]
3 changes: 2 additions & 1 deletion resources/before_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ <h1>NETL Life Cycle Inventory Data Process Document File</h1>
<nav>
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#metadata">Metadata</a></li>
<li><a href="#process-description">Description</a></li>
<li><a href="#methods">Methods</a></li>
<li><a href="#data">Data</a></li>
<li><a href="#document-control-information">Citation</a></li>
</ul>
</nav>
Expand Down
28 changes: 28 additions & 0 deletions resources/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.table-wrapper {
overflow-x: scroll;
max-height:900px;
}

.table-wrapper > table > thead > tr {
position: sticky;
top: 0;
background-color: white;
}


.horizontal-scroll-except-first-column {
overflow-x: auto;
max-height:900px;
}

.horizontal-scroll-except-first-column > table > * > tr > th:first-child,
.horizontal-scroll-except-first-column > table > * > tr > td:first-child {
position: sticky;
left: 0;
z-index: 2;
background-color: white;
}

dt {
font-weight: bold;
}
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

setup(
name="up_template",
version="3.0.0",
version="4.5.0",
license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
packages=['up_template'],
install_requires=[
"netlolca @ git+https://github.com/NETL-RIC/netlolca#egg=netlolca",
"openpyxl",
"pandas",
"sympy",
"tabulate",
Expand All @@ -36,7 +37,7 @@
long_description_content_type="text/markdown",
url="https://github.com/NETL-RIC/up_template",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication',
'Programming Language :: Python :: 3',
Expand Down
2 changes: 1 addition & 1 deletion up_template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
"version": "3.13.5"
}
},
"nbformat": 4,
Expand Down
Loading