Skip to content

Commit 68a9cba

Browse files
committed
split input-output into two files
1 parent c07c718 commit 68a9cba

File tree

10 files changed

+178
-139
lines changed

10 files changed

+178
-139
lines changed

.vitepress/sidebar.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,12 @@ export function getSidebar() {
137137
link: '/guides/build-iapp/manage-access',
138138
},
139139
{
140-
text: 'Inputs and Outputs',
141-
link: '/guides/build-iapp/inputs-and-outputs',
140+
text: 'Inputs',
141+
link: '/guides/build-iapp/inputs',
142+
},
143+
{
144+
text: 'Outputs',
145+
link: '/guides/build-iapp/outputs',
142146
},
143147

144148
{

src/guides/build-iapp/advanced/access-confidential-assets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The SMS currently supports 3 types of secrets:
3131
variable. It is owned by the developer of the application. It can be any kind
3232
of data (API key, private key, token, ..) as long as it respects the size
3333
limit (max. 4096 kB).
34-
2. [Requester secrets](/guides/build-iapp/inputs-and-outputs#access-requester-secrets):
34+
2. [Requester secrets](/guides/build-iapp/inputs#access-requester-secrets):
3535
These secrets are directly accessible from the application as environment
3636
variables, as long as the requester has decided to share them with it. These
3737
secrets can be any kind of data as long as they respect the size limit (max.
@@ -63,4 +63,4 @@ graph TD
6363
You now understand how these three kinds of confidential assets work on iExec,
6464
you can go one step further by learning how to manipulate them:
6565

66-
- [Access to a Protected Data](/guides/build-iapp/inputs-and-outputs)
66+
- [Access to a Protected Data](/guides/build-iapp/inputs#protected-data)

src/guides/build-iapp/advanced/build-your-first-tdx-iapp.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ EXPERIMENTAL_TDX_APP=true iapp run <app-address>
276276

277277
- **[Debugging Your iApp](/guides/build-iapp/debugging)** - Troubleshoot
278278
execution issues and TDX-specific problems
279-
- **[Inputs and Outputs](/guides/build-iapp/inputs-and-outputs)** - Handle data
279+
- **[Inputs](/guides/build-iapp/inputs)** - Handle data inputs
280+
- **[Outputs](/guides/build-iapp/outputs)** - Handle data outputs
280281
in TEE environment with TDX
281282
- **[iApp Access Control and Pricing](/guides/build-iapp/manage-access)** -
282283
Configure access control for your TDX applications

src/guides/build-iapp/debugging.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ except Exception as e:
169169

170170
Continue improving your iApp:
171171

172-
- **[Inputs and Outputs](/guides/build-iapp/inputs-and-outputs)** - Handle data
172+
- **[Inputs](/guides/build-iapp/inputs)** - Handle data inputs
173+
- **[Outputs](/guides/build-iapp/outputs)** - Handle data outputs
173174
in TEE
174-
- **[How to Get and Decrypt Results](/guides/build-iapp/inputs-and-outputs)** -
175+
- **[How to Get and Decrypt Results](/guides/build-iapp/outputs)** -
175176
Retrieve results

src/guides/build-iapp/inputs-and-outputs.md renamed to src/guides/build-iapp/inputs.md

Lines changed: 8 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
2-
title: Inputs and Outputs
2+
title: Inputs
33
description:
4-
Understand the different input types and output formats for iApp in the TEE
4+
Understand the different input types available to your iApp in the TEE
55
environment
66
---
77

8-
# 📥📤 Inputs and Outputs
8+
# 📥 Inputs
99

1010
**Your iApp runs inside a secure TEE environment with access to different types
1111
of inputs.** Understanding what data you can access, how to access it, and when
1212
to use each type is crucial for building effective privacy-preserving
1313
applications.
1414

15-
This guide covers all input types available to your iApp and how to generate
16-
proper outputs that users can retrieve and decrypt.
15+
This guide covers all input types available to your iApp and how to access them
16+
within the TEE environment.
1717

1818
## Two Perspectives on Inputs
1919

@@ -356,124 +356,6 @@ const processProtectedDataResponse =
356356
});
357357
```
358358

359-
## Creating Outputs
360-
361-
Your iApp must generate outputs in the `IEXEC_OUT` directory. **Every iApp must
362-
create a `computed.json` file** with metadata about the computation.
363-
364-
### Basic Output Structure
365-
366-
::: code-group
367-
368-
```python [Python]
369-
import os
370-
import json
371-
372-
# Get output directory
373-
iexec_out = os.environ['IEXEC_OUT']
374-
375-
# Create your result file
376-
result_data = {
377-
"analysis": "positive sentiment",
378-
"confidence": 0.92,
379-
"processed_at": "2024-01-15T10:30:00Z"
380-
}
381-
382-
# Save main result
383-
with open(f"{iexec_out}/result.json", 'w') as f:
384-
json.dump(result_data, f)
385-
386-
# REQUIRED: Create `computed.json` metadata
387-
computed_metadata = {
388-
"deterministic-output-path": f"{iexec_out}/result.json",
389-
"execution-timestamp": "2024-01-15T10:30:00Z",
390-
"app-version": "1.0.0"
391-
}
392-
393-
with open(f"{iexec_out}/computed.json", 'w') as f:
394-
json.dump(computed_metadata, f)
395-
```
396-
397-
```javascript [JavaScript]
398-
const fs = require('fs');
399-
const path = require('path');
400-
401-
// Get output directory
402-
const iexecOut = process.env.IEXEC_OUT;
403-
404-
// Create your result file
405-
const resultData = {
406-
analysis: 'positive sentiment',
407-
confidence: 0.92,
408-
processed_at: '2024-01-15T10:30:00Z',
409-
};
410-
411-
// Save main result
412-
fs.writeFileSync(
413-
path.join(iexecOut, 'result.json'),
414-
JSON.stringify(resultData, null, 2)
415-
);
416-
417-
// REQUIRED: Create computed.json metadata
418-
const computedMetadata = {
419-
'deterministic-output-path': path.join(iexecOut, 'result.json'),
420-
'execution-timestamp': '2024-01-15T10:30:00Z',
421-
'app-version': '1.0.0',
422-
};
423-
424-
fs.writeFileSync(
425-
path.join(iexecOut, 'computed.json'),
426-
JSON.stringify(computedMetadata, null, 2)
427-
);
428-
```
429-
430-
:::
431-
432-
### Output Best Practices
433-
434-
1. **Always create `computed.json`** - This is mandatory
435-
2. **Use descriptive filenames** - `analysis_result.json`, not `output.txt`
436-
3. **Include metadata** - Timestamps, versions, parameters used
437-
4. **Structure your data** - Use JSON for structured results
438-
5. **Keep files reasonable** - Large outputs increase retrieval time and may hit
439-
memory limits
440-
6. **Memory awareness** - TEE enclave memory is limited, avoid generating
441-
multi-GB outputs
442-
443-
### Example: Multi-file Output
444-
445-
```python
446-
import os
447-
import json
448-
449-
iexec_out = os.environ['IEXEC_OUT']
450-
451-
# Create multiple output files
452-
summary = {"total_processed": 1000, "success_rate": 0.95}
453-
with open(f"{iexec_out}/summary.json", 'w') as f:
454-
json.dump(summary, f)
455-
456-
# Create a detailed report
457-
with open(f"{iexec_out}/detailed_report.txt", 'w') as f:
458-
f.write("Detailed analysis results...\n")
459-
460-
# Create visualization data
461-
chart_data = {"labels": ["A", "B", "C"], "values": [10, 20, 30]}
462-
with open(f"{iexec_out}/chart_data.json", 'w') as f:
463-
json.dump(chart_data, f)
464-
465-
# Required metadata file
466-
computed = {
467-
"deterministic-output-path": f"{iexec_out}/summary.json",
468-
"additional-files": [
469-
f"{iexec_out}/detailed_report.txt",
470-
f"{iexec_out}/chart_data.json"
471-
]
472-
}
473-
with open(f"{iexec_out}/computed.json", 'w') as f:
474-
json.dump(computed, f)
475-
```
476-
477359
## Testing Inputs Locally
478360

479361
Use iApp Generator to test different input types:
@@ -595,13 +477,13 @@ save_report(report)
595477

596478
## What's Next?
597479

598-
**You now understand all input types and output requirements!**
480+
**You now understand all input types available to your iApp!**
599481

600482
Continue building with these guides:
601483

484+
- **[Outputs](/guides/build-iapp/outputs)** - Learn how to generate and structure
485+
your iApp outputs
602486
- **[App Access Control and Pricing](/guides/build-iapp/manage-access)** -
603487
Control who can use your iApp
604488
- **[Debugging Your iApp](/guides/build-iapp/debugging)** - Troubleshoot
605489
execution issues
606-
- **[How to Get and Decrypt Results](/guides/build-iapp/inputs-and-outputs)** -
607-
User-side result handling

src/guides/build-iapp/outputs.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: Outputs
3+
description:
4+
Learn how to generate and structure outputs from your iApp in the TEE
5+
environment
6+
---
7+
8+
# 📤 Outputs
9+
10+
**Your iApp must generate outputs that users can retrieve and decrypt.** Understanding
11+
how to structure your outputs, create the required metadata, and follow best
12+
practices is essential for building effective privacy-preserving applications.
13+
14+
This guide covers how to generate outputs from your iApp and ensure they can be
15+
properly retrieved by users.
16+
17+
## Creating Outputs
18+
19+
Your iApp must generate outputs in the `IEXEC_OUT` directory. **Every iApp must
20+
create a `computed.json` file** with metadata about the computation.
21+
22+
### Basic Output Structure
23+
24+
::: code-group
25+
26+
```python [Python]
27+
import os
28+
import json
29+
30+
# Get output directory
31+
iexec_out = os.environ['IEXEC_OUT']
32+
33+
# Create your result file
34+
result_data = {
35+
"analysis": "positive sentiment",
36+
"confidence": 0.92,
37+
"processed_at": "2024-01-15T10:30:00Z"
38+
}
39+
40+
# Save main result
41+
with open(f"{iexec_out}/result.json", 'w') as f:
42+
json.dump(result_data, f)
43+
44+
# REQUIRED: Create `computed.json` metadata
45+
computed_metadata = {
46+
"deterministic-output-path": f"{iexec_out}/result.json",
47+
"execution-timestamp": "2024-01-15T10:30:00Z",
48+
"app-version": "1.0.0"
49+
}
50+
51+
with open(f"{iexec_out}/computed.json", 'w') as f:
52+
json.dump(computed_metadata, f)
53+
```
54+
55+
```javascript [JavaScript]
56+
const fs = require('fs');
57+
const path = require('path');
58+
59+
// Get output directory
60+
const iexecOut = process.env.IEXEC_OUT;
61+
62+
// Create your result file
63+
const resultData = {
64+
analysis: 'positive sentiment',
65+
confidence: 0.92,
66+
processed_at: '2024-01-15T10:30:00Z',
67+
};
68+
69+
// Save main result
70+
fs.writeFileSync(
71+
path.join(iexecOut, 'result.json'),
72+
JSON.stringify(resultData, null, 2)
73+
);
74+
75+
// REQUIRED: Create computed.json metadata
76+
const computedMetadata = {
77+
'deterministic-output-path': path.join(iexecOut, 'result.json'),
78+
'execution-timestamp': '2024-01-15T10:30:00Z',
79+
'app-version': '1.0.0',
80+
};
81+
82+
fs.writeFileSync(
83+
path.join(iexecOut, 'computed.json'),
84+
JSON.stringify(computedMetadata, null, 2)
85+
);
86+
```
87+
88+
:::
89+
90+
### Output Best Practices
91+
92+
1. **Always create `computed.json`** - This is mandatory
93+
2. **Use descriptive filenames** - `analysis_result.json`, not `output.txt`
94+
3. **Include metadata** - Timestamps, versions, parameters used
95+
4. **Structure your data** - Use JSON for structured results
96+
5. **Keep files reasonable** - Large outputs increase retrieval time and may hit
97+
memory limits
98+
6. **Memory awareness** - TEE enclave memory is limited, avoid generating
99+
multi-GB outputs
100+
101+
### Example: Multi-file Output
102+
103+
```python
104+
import os
105+
import json
106+
107+
iexec_out = os.environ['IEXEC_OUT']
108+
109+
# Create multiple output files
110+
summary = {"total_processed": 1000, "success_rate": 0.95}
111+
with open(f"{iexec_out}/summary.json", 'w') as f:
112+
json.dump(summary, f)
113+
114+
# Create a detailed report
115+
with open(f"{iexec_out}/detailed_report.txt", 'w') as f:
116+
f.write("Detailed analysis results...\n")
117+
118+
# Create visualization data
119+
chart_data = {"labels": ["A", "B", "C"], "values": [10, 20, 30]}
120+
with open(f"{iexec_out}/chart_data.json", 'w') as f:
121+
json.dump(chart_data, f)
122+
123+
# Required metadata file
124+
computed = {
125+
"deterministic-output-path": f"{iexec_out}/summary.json",
126+
"additional-files": [
127+
f"{iexec_out}/detailed_report.txt",
128+
f"{iexec_out}/chart_data.json"
129+
]
130+
}
131+
with open(f"{iexec_out}/computed.json", 'w') as f:
132+
json.dump(computed, f)
133+
```
134+
135+
## What's Next?
136+
137+
**You now understand how to generate proper outputs from your iApp!**
138+
139+
Continue building with these guides:
140+
141+
- **[Inputs](/guides/build-iapp/inputs)** - Learn about the different input types
142+
available to your iApp
143+
- **[App Access Control and Pricing](/guides/build-iapp/manage-access)** -
144+
Control who can use your iApp
145+
- **[Debugging Your iApp](/guides/build-iapp/debugging)** - Troubleshoot
146+
execution issues
147+
- **[How to Get and Decrypt Results](/guides/use-iapp/getting-started)** -
148+
User-side result handling

src/guides/manage-data/handle-schemas-dataset-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ don't match, you'll get runtime errors when processing the data.
253253
:::
254254

255255
**Ready to build an iApp?** Check out our detailed
256-
[Inputs and Outputs guide](/guides/build-iapp/inputs-and-outputs) to learn how
256+
[Inputs guide](/guides/build-iapp/inputs) to learn how
257257
to access schema fields inside your iApp using the deserializer.
258258

259259
## Next Steps

src/protocol/ai.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ docker run --rm hello-pytorch
169169
application
170170
- **[Build Intel TDX App](/guides/build-iapp/advanced/build-your-first-tdx-iapp)** -
171171
TDX applications for AI workloads
172-
- **[Inputs and Outputs](/guides/build-iapp/inputs-and-outputs)** - Handle data
172+
- **[Inputs](/guides/build-iapp/inputs)** - Handle data inputs
173+
- **[Outputs](/guides/build-iapp/outputs)** - Handle data outputs
173174
flow in TEE environment
174175

175176
### Explore Examples

0 commit comments

Comments
 (0)