Skip to content

Commit

Permalink
Add docs for the file agent and examples directory (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
mssun committed Jun 4, 2020
1 parent f4fff72 commit 52ee432
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -51,6 +51,8 @@ platform, making computation on privacy-sensitive data safe and simple.
- [Configurations in Teaclave](config)
- [Data Center Attestation Service](dcap)
- [Dockerfile and Compose File](docker)
- [Examples](examples)
- [File Agent](file_agent)
- [Function Executors](executor)
- [Keys and Certificates](keys)
- [RPC](rpc)
Expand Down
24 changes: 23 additions & 1 deletion examples/README.md
@@ -1 +1,23 @@
examples
---
permalink: /examples
---

# Examples

In this directory, we implement some examples to illustrate how to register
input/output data for a function, create and invoke a task and get execution
results with the Teclave's client SDK in both single and multi-party setups.

Before trying these examples, please make sure all services in the Teaclave
platform has been properly launched. Also, for examples implemented in Python,
don't forget to set the `PYTHONPATH` to the `sdk` path so that the scripts can
successfully import the `teaclave` module.

For instance, use the following command to invoke an echo function in Teaclave:

```
$ PYTHONPATH=../../sdk/python python3 builtin_echo.py 'Hello, Teaclave!'
```

Please checkout the sources of these examples to learn more about the process of
invoking a function in Teaclave.
17 changes: 17 additions & 0 deletions file_agent/README.md
@@ -0,0 +1,17 @@
---
permalink: /file-agent
---

# File Agent

The file agent is a component in the execution service. The main function is to
handle file downloading/uploading from and to various storage service providers
(e.g., AWS S3).

Before executing a task, the execution service will use the file agent to
prepare any registered input files comes with the task. For example, the
registered file input could be a presigned URL from AWS S3. The file agent will
download and prepare the file in local. With these files in the local storage,
the executor can finally invoke the function. Similarly, after the task is
successfully executed, the file agent will help to upload the output files to
a remote file storage like S3.
8 changes: 4 additions & 4 deletions tests/functional/enclave/src/frontend_service.rs
Expand Up @@ -58,13 +58,13 @@ fn test_update_input_file() {
let cmac = FileAuthTag::mock();
let crypto_info = FileCrypto::default();

let request = RegisterInputFileRequest::new(url.clone(), cmac, crypto_info);
let request = RegisterInputFileRequest::new(url, cmac, crypto_info);
let response = authorized_client().register_input_file(request);
assert!(response.is_ok());

let old_data_id = response.unwrap().data_id;
let new_url = Url::parse("https://external-storage.com/filepath-new?presigned_token").unwrap();
let update_request = UpdateInputFileRequest::new(old_data_id.clone(), new_url.clone());
let update_request = UpdateInputFileRequest::new(old_data_id.clone(), new_url);
let update_response = authorized_client().update_input_file(update_request);
assert!(update_response.is_ok());
assert!(old_data_id != update_response.unwrap().data_id);
Expand All @@ -89,13 +89,13 @@ fn test_update_output_file() {
let url = Url::parse("https://external-storage.com/filepath?presigned_token").unwrap();
let crypto_info = FileCrypto::default();

let request = RegisterOutputFileRequest::new(url.clone(), crypto_info);
let request = RegisterOutputFileRequest::new(url, crypto_info);
let response = authorized_client().register_output_file(request);
assert!(response.is_ok());

let old_data_id = response.unwrap().data_id;
let new_url = Url::parse("https://external-storage.com/filepath-new?presigned_token").unwrap();
let update_request = UpdateOutputFileRequest::new(old_data_id.clone(), new_url.clone());
let update_request = UpdateOutputFileRequest::new(old_data_id.clone(), new_url);
let update_response = authorized_client().update_output_file(update_request);
assert!(update_response.is_ok());
assert!(old_data_id != update_response.unwrap().data_id);
Expand Down

0 comments on commit 52ee432

Please sign in to comment.