nrelWattileExt is a SkySpark extension for interfacing Wattile, a Python package for probabilistic prediction of building energy use developed by NREL's Intelligent Campus team. This package is developed and maintained by the National Renewable Energy Laboratory.
Build instructions:
- Create a local clone of this repository on a computer with a working copy of SkySpark.
- From the command line, change directory to the SkySpark root directory.
- Execute
bin/fan /path/to/nrelWattileExt/build.fan
.- On Linux, you may need to
chmod +x bin/fan
first. - Output pod will be
lib/fan/nrelWattileExt.pod
(relative to SkySpark root).
- On Linux, you may need to
- Execute
bin/fan docgen
to regenerate documentation.
Build instructions are the same for Windows except paths use backslashes \
and fan
becomes fan.bat
.
Note that all dependencies need to be in lib/fan
(relative to SkySpark root);
the build script will not find pods located in var/lib/fan
.
Select a set of installation instructions below that corresponds to how you obtained the nrelWattileExt extension. Following installation, you must enable the nrelWattile extension in the Exts tab of the SkySpark Settings app within each project that needs access to the functions.
If you built from source, all that is needed to install the extension is to start (or restart) SkySpark.
- Download a
nrelWattileExt.pod
release from GitHub. - Copy
nrelWattileExt.pod
into thelib/fan/
directory of your SkySpark installation. - Set ownership permissions correctly on the pod to match the other pods in your SkySpark installation (Linux/Mac).
- From the command line, change directory to the SkySpark root directory.
- Execute
bin/fan docgen
to regenerate documentation.- Optional; the functions will work without this step but the Doc app won't show any function documentation.
- On Linux, you may need to
chmod +x bin/fan
first.
- Start (or restart) SkySpark.
TO DO (Future)
To use nrelWattileExt, you must have:
- Docker installed and working with SkySpark
- A local Docker image built from the nrelWattileExt repo registered with a
tag you can access from SkySpark (e.g.
"wattile"
); see Docker below
For more information, see the nrelWattileExt documentation within SkySpark.
To build the required Docker image containing Wattile:
-
Install and launch Docker
-
Clone the nrelWattileExt repository branch or release corresponding to your current nrelWattileExt version
-
From the repository root directory, run:
docker build --tag="wattile" .
Optionally, to specify a Wattile release version or branch other than the default:
docker build --build-arg="WATTILE_RELEASE=X.Y.Z" --tag="wattile" .
or
docker build --no-cache --build-arg="WATTILE_BRANCH=branch" --tag="wattile" .
(The
--no-cache
option is used here to ensure that you do not accidentally build from an outdated, cached local copy of the repository.)
If you did not build the Docker image on the same system where SkySpark runs, you will also need to copy and install the Docker image on your SkySpark system:
- Run
docker save wattile | gzip > wattile.tar.gz
(this may take a while) - Copy
wattile.tar.gz
to the target system - Run
docker load --input /path/to/wattile.tar.gz
The Docker image is now ready for use with SkySpark.
When running a Docker container based on Hxpy, SkySpark mounts the project
io/
directory within the Docker container at /io/
. When SkySpark is running
on Linux, permissions conflicts arise if the user ID (UID) and group ID (GID) of
the user running SkySpark do not match the UID and GID of the user running
Wattile within the Docker container: files and folders owned by the SkySpark
user may not be readable and writable by the Wattile user and vice versa.
Therefore, when SkySpark is running on Linux, you must use one of the following options to ensure SkySpark and Wattile share file access:
-
Build the Docker image such that the container user has the same UID and GID as the host system's SkySpark user. If building the image on the host system, use:
docker build \ --build-arg HOST_UID="$(id -u)" \ --build-arg HOST_GID="$(id -g)" \ ...
Where
...
represents the remaining build options or arguments (see above).If building the image on a different system, first identify the UID and GID of the SkySpark user be executing the
id
command on the host system. Then, with theuid
andgid
numbers from the host system, run:docker build \ --build-arg HOST_UID="uid" \ --build-arg HOST_GID="gid" \ ...
This is the recommended option.
-
Run SkySpark as a user whose UID and GID match the defaults from Wattile Docker image:
- UID = 1022
- GID = 1022
This option will work, but changing the SkySpark user may have unintended consequences (such as breaking access permissions for existing files).
-
Modify ownership for the
io/
directory to be readable and writable by others:chmod o+wrx /path/to/io/
. This option will also work but is discouraged for security reasons.
Function documentation is available in the SkySpark Doc app under nrelWattile or within the Docs interface in the Code app.
nrelWattileExt is a SkySpark resource extension, that is, it provides the
set of Axon functions as a resource for SkySpark users. The functions are
stored in the Trio-formatted files within lib/
:
taskFuncs.trio
: Functions used to define Python interaction task(s)pythonFuncs.trio
: Functions for interacting with Python (internal use)supportFuncs.trio
: Support and convenience functions for interacting with Wattile models and their proxy records in SkySparkutilityFuncs.trio
: Other utility functions (internal use)
The simplest development workflow is to import these functions into SkySpark,
make changes Code app (and test via Tools), export back to Trio format, and
update the corresponding file(s) in the repo. Workflows for importing functions
to SkySpark and exporting functions from SkySpark are described below. These
istructions assume you have the nrelUtility extension installed (contains
importFunctions()
and exportFunctions()
).
For more guidance on developing resource extensions, see the SkyFoundry Resource Extension App Note.
Note: All paths below are relative to repository root directory.
-
Launch SkySpark and log in with an admin or superuser account.
-
Create a project to use for development and make it the active project. (These instructions assume your project is named
"wattile_test"
.) -
Within the Settings app, Exts tab, enable:
- docker
- py
- nrelUtility
-
Within the Tools app, Files tab, upload some or all of following files from
lib/
directory toproj > wattile_test > io
, according to your development needs:taskFuncs.trio
pythonFuncs.trio
supportFuncs.trio
utilityFuncs.trio
-
(Optional) Pick a marker (or "flag") tag to attach to each imported function to facilitate easy querying for later export.
- These instructions assume your flag tag is
wattileDev
. - For organization, you may want to use a different flag tag for each file.
- These instructions assume your flag tag is
-
In the Tools app, Shell tab, execute the following for each file
x.trio
that contains functions you need to import:importFunctions(`io/x.trio`, {merge:{wattileDev}, commit})
Alternatively, if you are not using a flag tag:
importFunctions(`io/x.trio`, {commit})
-
To verify that the functions were successfully imported, ceck the Code app or query for them via the Shell:
readAll(func) // All functions
or
readAll(func and wattileDev) // Flagged functions only
Note that if any of the imported functions has a name conflict with an existing
function, then both versions will now be present in your project database. You
will need to manually resolve any conflicts by removing or renaming the
duplicate function record(s). Hint: check the function record mod
tags.
Note: All paths below are relative to repository root directory.
-
In SkySpark, construct a query that returns the function(s) you wish to export. If you used a flag tag during import (e.g.
wattileDev
), your query will probably look something like this:func and wattileDev
(If you did not use a flag tag, you will need a different query, such as specifying the name or each function combined with the
or
keyword.)You can test your query from the Tools app, Shell tab, by executing it directly and inspecting the records that SkySpark returns.
-
In the Tools app, Shell tab, execute the following code to query your functions and export them to a Trio file.
readAll(func and wattileDev).exportFunctions(`io/x.trio`, {merge:{-wattileDev}})
- The query within
readAll()
should match what you developed in Step 1 above - Modify
x.trio
to the desired name of your output file - If you did not use a flag tag, you do not need to remove it with the
merge
option ofexportFunctions()
.
-
Download
x.trio
from SkySpark via the Tools app, Files tab (or copy it via your file system), then place it in thelib/
directory. -
Commit to Git.
Alternative Workflow:
-
Develop your query per Step 1 above
-
In the Tools app, Shell tab, execute the following code to query your functions and prepare them for export:
readAll(func and wattileDev).exportFunctions(null, {preview, merge:{-wattileDev}})
- The query within
readAll()
should match what you developed in Step 1 above - If you did not use a flag tag, you do not need to remove it with the
merge
option ofexportFunctions()
.
-
On the right-hand side of the Shell, find the view select button (it will likey say "Table") and change it to "Trio".
-
Manually copy the Trio-formatted function record(s) from the Shell to the relevant file(s) in the
lib/
directory, replacing the existing versions as applicable.
The test/
subdirectory contains resources and instructions for setting up a
minimal SkySpark test environment for developing and testing functions and workflows related to nrelWattileExt.
This software is licensed for use under the terms of the Berkeley Software
Distribution 3-clause (BSD-3) license; see LICENSE.md
. NREL software record
number: SWR-24-73.