|
1 | | -# ODTP Component Template |
| 1 | +# odtp-pygwalker |
2 | 2 |
|
3 | | -This is a template that facilitates the development of new `odtp-components`. An `odtp` compatible component is a docker container able to perform a functional unit of computing in the digital twin. You can think of it as a blackbox that takes inputs files and/or parameters and perfom a task. Usually this lead to some files as a result (Ephemeral component), or to a visualization (Interactive component). |
| 3 | +CSV interactive visualization |
4 | 4 |
|
5 | | -Internally a component will run a bash script `./app/app.sh` that must include the commands for running your tool, and managing the input/output logic. While input files are located in the folder `/odtp/odtp-input`, parameters values are represented by environment variables within the component. In this way you can access to them by using `$` before the name of your variable. Finally, the output files generated are requested to be placed in `/odtp/odtp-output/`. |
| 5 | +| Tool Info | Links | |
| 6 | +| --- | --- | |
| 7 | +| Original Tool | [https://github.com/Kanaries/pygwalker-in-streamlit](https://github.com/Kanaries/pygwalker-in-streamlit) | |
| 8 | +| Current Tool Version | [commit-hash](link-to-commit-hash) | |
6 | 9 |
|
7 | | -## How to clone this repository? |
8 | 10 |
|
9 | | -> [!NOTE] |
10 | | -> This repository makes use of submodules. Therefore, when cloning it you need to include them. |
11 | | -> |
12 | | -> `git clone --recurse-submodules https://github.com/odtp-org/odtp-component-template` |
| 11 | +## ODTP command |
13 | 12 |
|
| 13 | +``` |
| 14 | +odtp new odtp-component-entry \ |
| 15 | +--name odtp-pygwalker \ |
| 16 | +--component-version 0.1.0 \ |
| 17 | +--repository https://github.com/caviri/odtp-pygwalker |
| 18 | +``` |
14 | 19 |
|
15 | | -## How to create an odtp compatible component using this template? |
16 | | - |
17 | | -1. Identify which parameters would you like to expose. |
18 | | -2. Configure the Dockerfile to install all the OS requirements needed for your tool to run. |
19 | | - 1. (Optional) If your tool requires python, and the dependencies offered in the repo are not compatible with the docker image you can configure custom dependencies in requirements.txt |
20 | | -3. Configure the `app/app.sh` file to: |
21 | | - 1. Clone the repository of your tool and checkout to one specific commit. |
22 | | - 2. (Optional) If your app uses a config file (i.e. `config.yml` or `config.json`), you need to provide a templace including placeholders for the variables you would like to expose. Placeholders can be defined by using double curly braces wrapping the name of the variable, such as `{{VARIABLE}}`. Then you can run `python3 /odtp/odtp-component-client/parameters.py PATH_TO_TEMPLATE PATH_TO_OUTPUT_CONFIG_FILE` and every placeholder will be replaced by the value in the environment variable. |
23 | | - 3. Copy (`cp -r`) or create symbolic links (`ln -s`) to locate the input files in `/odpt/odtp-input/` in the folder. |
24 | | - 4. Run the tool. You can access to the parameters as environemnt variables (i.e. `$PARAMETER_A`) |
25 | | - 5. Manage the output exporting. At the end of the component execution all generated output should be located in `/odtp/odtp-output`. Copy all output files into this folder. |
26 | | -4. Describe all the metadata in `odtp.yml`. Please check below for instructions. |
27 | | -5. Publish your tool in the ODTP Zoo. (Temporaly unavailable) |
28 | | - |
29 | | -### Semantic Validation |
30 | | - |
31 | | -ODTP will be able to validate the input/output files. In order to do this we use SHACL validation. However, the developer should provide a schema of the input/output schema. This section is still under development and it will be available soon. |
32 | | - |
33 | | -## Internal data structure of a component |
34 | | - |
35 | | -It's important to remark that when the container is built an specific folder structure is generated: |
36 | | - |
37 | | -- `/odtp`: The main folder. |
38 | | -- `/odtp/odtp-component-client`: This is the odtp client that will manage the execution, logging, and input/output functions of the component. It is include as a submodule, and the user doesn't need to modify it. |
39 | | -- `/odtp/odtp-app`: This folder have the content of `/app` folder in this template. It contains the tool execution bash script and the tool configuration files. |
40 | | -- `/odtp/odtp-workdir`: This is the working directory where the tool repository should be placed and all the middle files such as cache folders. |
41 | | -- `/odtp/odtp-input`: Input folder that is be mounted as volume for the docker container. |
42 | | -- `/odtp/odtp-output`: Output folder that is mounted as volume for the docker container. |
43 | | -- `/odtp/odtp-logs`: Folder reserved for internal loggings. |
44 | | -- `/odtp/odtp-config`: Folder reserved for odtp configuration. |
45 | | - |
46 | | -## Testing the component |
47 | | - |
48 | | -There are 3 main ways in which you can test a component and the different odtp features. |
49 | | - |
50 | | -1. Testing it as a docker container |
51 | | -2. Testing it as a single component using `odtp` |
52 | | -3. Testing it in a `odtp` digital twin execution |
| 20 | +## Data sheet |
53 | 21 |
|
54 | | -When developing we recomend to start by testing the component via docker and then follow with the others. |
| 22 | +### Parameters |
55 | 23 |
|
56 | | -### Testing the component as a docker container |
| 24 | +No parameter |
57 | 25 |
|
58 | | -The user will need to manually create the input/output folders and build the docker image. |
| 26 | +### Input Files |
59 | 27 |
|
60 | | -1. Prepare the following folder structure: |
| 28 | +| File/Folder | Description | |
| 29 | +| --- | --- | |
| 30 | +| Input | Folder where streamlit compatible files are located | |
61 | 31 |
|
62 | | -``` |
63 | | -- testing-folder |
64 | | - - data-input |
65 | | - - data-output |
66 | | -``` |
| 32 | +### Output Files |
67 | 33 |
|
68 | | -Place all required input files in `testing-folder/data-input`. |
| 34 | +No output |
69 | 35 |
|
70 | | -2. Create your `.env` file with the following parameters. |
| 36 | +## Tutorial |
71 | 37 |
|
72 | | -``` |
73 | | -# ODTP COMPONENT VARIABLES |
74 | | -PARAMETER-A=..... |
75 | | -PARAMETER-B=..... |
76 | | -``` |
| 38 | +### How to run this component as docker |
77 | 39 |
|
78 | | -3. Build the dockerfile. |
| 40 | +Build the dockerfile |
79 | 41 |
|
80 | 42 | ``` |
81 | | -docker build -t odtp-component . |
| 43 | +docker build -t odtp-pygwalker . |
82 | 44 | ``` |
83 | 45 |
|
84 | | -4. Run the following command. |
| 46 | +Run the following command. Mount the correct volumes for input/output folders. |
85 | 47 |
|
86 | 48 | ``` |
87 | | -docker run -it --rm \ |
88 | | --v {PATH_TO_YOUR_INPUT_VOLUME}:/odtp/odtp-input \ |
89 | | --v {PATH_TO_YOUR_INPUT_VOLUME}:/odtp/odtp-output \ |
90 | | ---env-file .env \ |
91 | | -odtp-component |
92 | | -``` |
93 | | - |
94 | | -This command will run the component. If you want debug some errors and execute the docker in an interactive manner, you can use the flag `--entrypoint bash` when running docker. |
95 | | - |
96 | | -Also if your tool is interactive such as an Streamlit app, don't forget to map the ports by using `-p XXXX:XXXX`. |
97 | | - |
98 | | -### Testing the component as part of odtp |
99 | | - |
100 | | -To execute the command as part of `odtp` please refer to our `odtp` documentation: |
101 | | - |
102 | | -https://odtp-org.github.io/odtp-manuals/ |
103 | | - |
104 | | -## `odtp.yml` |
105 | | - |
106 | | -ODTP requires a set of metadata to work. These fields should be filled by the developers. |
107 | | - |
108 | | -```yml |
109 | | -# This file should contain basic component information for your component. |
110 | | -component-name: Component Name |
111 | | -component-author: Component Author |
112 | | -component-version: Component Version |
113 | | -component-repository: Component Repository |
114 | | -component-license: Component License |
115 | | -component-type: ephemeral or interactive |
116 | | -component-description: Description |
117 | | -tags: |
118 | | - - tag1 |
119 | | - - tag2 |
120 | | - |
121 | | -# Information about the tools |
122 | | -tools: |
123 | | - - tool-name: tool's name |
124 | | - tool-author: Tool's author |
125 | | - tool-version: Tool version |
126 | | - tool-repository: Tool's repository |
127 | | - tool-license: Tool's license |
128 | | - |
129 | | -# If your tool require some secrets token to be passed as ENV to the component |
130 | | -# This won't be traced |
131 | | -secrets: |
132 | | - - name: Key of the argument |
133 | | - - description: Description of the secret |
134 | | - |
135 | | -# If the tool requires some building arguments such as Matlab license |
136 | | -build-args: |
137 | | - - name: Key of the argument |
138 | | - - description: Descriptio of the building argument |
139 | | - - secret: Bool |
140 | | - |
141 | | -# If applicable, ports exposed by the component |
142 | | -# Include Name, Description, and Port Value for each port |
143 | | -ports: |
144 | | - - name: PORT A |
145 | | - description: Description of Port A |
146 | | - port-value: XXXX |
147 | | - - name: PORT B |
148 | | - description: Description of Port B |
149 | | - port-value: YYYY |
150 | | - |
151 | | -# If applicable, parameters exposed by the component |
152 | | -# Datatype can be str, int, float, or bool. |
153 | | -parameters: |
154 | | - - name: PARAMETER A |
155 | | - default-value: DEFAULT_VALUE_A |
156 | | - datatype: DATATYPE_A |
157 | | - description: Description of Parameter A |
158 | | - parameter-bounds: # Boundaries for int and float datatype |
159 | | - - 0 # Lower bound |
160 | | - - inf # Upper bound |
161 | | - options: null |
162 | | - allow-custom-value: false # If true the user can add a custom value out of parameter-bounds, or options |
163 | | - |
164 | | - - name: PARAMETER B |
165 | | - default-value: DEFAULT_VALUE_B |
166 | | - datatype: DATATYPE_B |
167 | | - description: Description of Parameter B |
168 | | - parameter-bounds: null |
169 | | - options: # If your string parameter is limited to a few option, please list them here. |
170 | | - - OptionA |
171 | | - - OptionB |
172 | | - - OptionC |
173 | | - allow-custom-value: false # If true the user can add a custom value out of parameter-bounds, or options |
174 | | - |
175 | | -# If applicable, data-input list required by the component |
176 | | -data-inputs: |
177 | | - - name: INPUT A |
178 | | - type: TYPE_A # Folder or filetype |
179 | | - path: VALUE_A |
180 | | - description: Description of Input A |
181 | | - - name: INPUT B |
182 | | - type: TYPE_B # Folder or filetype |
183 | | - path: VALUE_B |
184 | | - description: Description of Input B |
185 | | - |
186 | | -# If applicable, data-output list produced by the component |
187 | | -data-output: |
188 | | - - name: OUTPUT A |
189 | | - type: TYPE_A # Folder or filetype |
190 | | - path: VALUE_A |
191 | | - description: Description of Output A |
192 | | - - name: OUTPUT B |
193 | | - type: TYPE_B # Folder or filetype |
194 | | - path: VALUE_B |
195 | | - description: Description of Output B |
196 | | - |
197 | | -# If applicable, path to schemas to perform semantic validation. |
198 | | -# Still under development. Ignore. |
199 | | -schema-input: PATH_TO_INPUT_SCHEMA |
200 | | -schema-output: PATH_TO_OUTPUT_SCHEMA |
201 | | - |
202 | | -# If applicable, define devices needed such as GPU. |
203 | | -devices: |
204 | | - gpu: Bool |
| 49 | +docker run -it --rm \ |
| 50 | +-v ./odtp-input:/odtp/odtp-input \ |
| 51 | +--env-file .env odtp-pygwalker |
205 | 52 | ``` |
206 | 53 |
|
207 | | -## Changelog |
208 | | -
|
209 | | -- v0.4.0 |
210 | | - - Update default Base and Python in Dockerfile to `ubuntu:22.04` and `python3.10` |
211 | | - |
212 | | -- v0.3.4 |
213 | | - - Inclusion of `secrets` and `build-args` in `odtp.yml` |
214 | | - - Tools as list |
215 | | - |
216 | | -- v0.3.3 |
217 | | - - Inclusion of boundaries conditions and options in `odtp.yml` parameters. |
218 | | - |
219 | | -- v0.3.2 |
220 | | - - Extended `odtp.yml` parameters and input/output definition. |
221 | | - - `odtp.requirements.txt` transfered to submodule `odtp-component-client`. |
222 | | - |
223 | | -- v0.3.1 |
224 | | - - Updating schema fields in `odtp.yml` to kebab-case. |
225 | | - |
226 | | -- v0.3.0 |
227 | | - - Turning `odtp-client` into a separate repository and adding it as a submodule in `odtp-component-client` |
228 | | - - Updating `app.sh` and tutorial. |
229 | | - - Updating `odtp.yml` file. |
230 | | - - Adding `.DS_Store` to `.gitignore` |
231 | | - |
232 | | -- v0.2.0 |
233 | | - - Compatible with ODTP v.0.2.0 only with platform / components |
234 | | - - Compatible with configuration text files |
235 | | - - Improved loging system |
236 | | - - Accepting Digital Twins, Executions, and steps, metadata. |
237 | | - - Including component versioning in `odtp.yml` |
238 | | - |
239 | | -- v0.1.0 |
240 | | - - Compatible with ODTP v.0.1.0 only with platform / components |
241 | | - - Compatible with configuration text files |
242 | | - |
243 | | -## Acknowledgments, Copyright, and Licensing |
244 | | - |
245 | | -### Acknowledgments and Funding |
246 | | - |
247 | | -This work is part of the broader project **O**pen **D**igital **T**win **P**latform of the **S**wiss **M**obility **S**ystem (ODTP-SMS) funded by Swissuniversities CHORD grant Track B - Establish Projects. ODTP-SMS project is a joint endeavour by the Center for Sustainable Future Mobility - CSFM (ETH Zürich) and the Swiss Data Science Center - SDSC (EPFL and ETH Zürich). |
248 | | -The Swiss Data Science Center (SDSC) develops domain-agnostic standards and containerized components to manage digital twins. This includes the creation of the Core Platform (both back-end and front-end), Service Component Integration Templates, Component Ontology, and the Component Zoo template. |
249 | | -The Center for Sustainable Future Mobility (CSFM) develops mobility services and utilizes the components produced by SDSC to deploy a mobility digital twin platform. CSFM focuses on integrating mobility services and collecting available components in the mobility zoo, thereby applying the digital twin concept in the realm of mobility. |
250 | | - |
251 | | -### Copyright |
252 | | - |
253 | | -Copyright © 2023-2024 Swiss Data Science Center (SDSC), www.datascience.ch. All rights reserved. |
254 | | -The SDSC is jointly established and legally represented by the École Polytechnique Fédérale de Lausanne (EPFL) and the Eidgenössische Technische Hochschule Zürich (ETH Zürich). This copyright encompasses all materials, software, documentation, and other content created and developed by the SDSC. |
255 | | - |
256 | | -### Intellectual Property (IP) Rights |
257 | | - |
258 | | -The Open Digital Twin Platform (ODTP) is the result of a collaborative effort between ETH Zurich (ETHZ) and the École Polytechnique Fédérale de Lausanne (EPFL). Both institutions hold equal intellectual property rights for the ODTP project, reflecting the equitable and shared contributions of EPFL and ETH Zürich in the development and advancement of this initiative. |
259 | | - |
260 | | -### Licensing |
261 | | - |
262 | | -The Service Component Integration Templates within this repository are licensed under the BSD 3-Clause "New" or "Revised" License. This license allows for broad compatibility and standardization, encouraging open use and contribution. For the full license text, please see the LICENSE file accompanying these templates. |
263 | | - |
264 | | -#### Distinct Licensing for Other Components |
265 | | - |
266 | | -- **Core Platform**: Open-source under AGPLv3. |
267 | | -- **Ontology**: Creative Commons Attribution-ShareAlike (CC BY-SA). |
268 | | -- **Component Zoo Template**: BSD-3 license. |
269 | | - |
270 | | -### Alternative Commercial Licensing |
271 | | - |
272 | | -Alternative commercial licensing options for the core platform and other components are available and can be negotiated through the EPFL Technology Transfer Office (https://tto.epfl.ch) or ETH Zürich Technology Transfer Office (https://ethz.ch/en/industry/transfer.html). |
273 | 54 |
|
274 | | -## Ethical Use and Legal Compliance Disclaimer |
| 55 | +## Developed by |
275 | 56 |
|
276 | | -Please note that this software should not be used to deliberately harm any individual or entity. Users and developers must adhere to ethical guidelines and use the software responsibly and legally. This disclaimer serves to remind all parties involved in the use or development of this software to engage in practices that are ethical, lawful, and in accordance with the intended purpose of the software. |
| 57 | +SDSC |
0 commit comments