In this section, let us create the actor from the Docker container and test it by sending a message.
Send Email Message From Actor¶
The default command for this container emails the message “Hello, World” or the message sent to it, which will be captured in the actor logs.
Create the actor as:
$ tapis actors create --repo taccuser/email-actor:1.0 \
-n email-actor \
-d "Test actor that emails Hello, World"
-e useremail_from='useremail' \
-e userpassword='password' \
-e useremail_to='useremail_to'
+----------------+----------------------------+
| Field | Value |
+----------------+----------------------------+
| id | w66kex1yD7Ql |
| name | email-actor |
| owner | taccuser |
| image | taccuser/email-actor:1.0 |
| lastUpdateTime | 2021-08-24T14:31:58.248860 |
| status | SUBMITTED |
+----------------+----------------------------+
Here, we are using the -e flag to set (optional) environment variables for the actor at creation time. These variables will be part of the “context” taken from the environment, as in the example python script above. For our example, we will pass our Gmail username and password as environment variables to the actor. These environment variables will not be visible to anyone else.
Note
Make sure to quote the email and password values. They usually contain
characters such as @ that have specific meaning in the UNIX shell. Quoting
these strings protects them from being interpreted. Failure to do so can cause
your create command to fail or behave unexpectedly.
The --repo flag points to the Docker Hub repo on which this actor is based,
the -n flag and -d flag attach a human-readable name and description to
the actor.
The resulting actor is assigned an id: w66kex1yD7Ql. The actor id can be
queried by
$ tapis actors show -v w66kex1yD7Ql
{
"id": "w66kex1yD7Ql",
"name": "email-actor",
"description": "Actor that emails the message",
"owner": "taccuser",
"image": "taccuser/email-actor:1.0",
"createTime": "2021-08-24T14:31:58.248Z",
"lastUpdateTime": "2021-08-24T14:31:58.248Z",
"defaultEnvironment": {
"useremail_from": "username_from@gmail.com"
"useremail_to": "username_to@gmail.com"
"userpassoword": "userpassword"
},
"gid": 862347,
"hints": [],
"link": "",
"mounts": [
{
"container_path": "/work",
"host_path": "/work",
"mode": "rw"
},
{
"container_path": "/corral",
"host_path": "/corral-repl/projects/SD2E-Community",
"mode": "rw"
}
],
"privileged": false,
"queue": "default",
"stateless": true,
"status": "READY",
"statusMessage": " ",
"token": true,
"uid": 862347,
"useContainerUid": false,
"webhook": "",
"_links": {
"executions": "https://api.sd2e.org/actors/v2/w66kex1yD7Ql/executions",
"owner": "https://api.sd2e.org/profiles/v2/sgopal",
"self": "https://api.sd2e.org/actors/v2/w66kex1yD7Ql"
}
}
Above, you can see the plain text name, description, environment variables that were passed on the command line. In addition, you can see the “status” of the actor is “READY”, meaning it is ready to receive and act on messages. Finally, you can list all actors visible to you with:
$ tapis actors list
+---------------+---------------+----------+-----------------------------+----------------------------+--------+-------+
| id | name | owner | image | lastUpdateTime | status | cronOn|
+---------------+---------------+----------+-----------------------------+----------------------------+--------+-------+
| w66kex1yD7Ql | email-actor | taccuser | taccuser/email-actor:1.0 | 2021-08-14T22:25:06.171Z | READY | False |
+---------------+---------------+----------+-----------------------------+----------------------------+--------+-------+
Submit a Message to the Actor¶
Next, let’s craft a simple message to send to the reactor. Messages can be plain text or in JSON format. When using the python actor libraries as in the example above, JSON-formatted messages are made available as python dictionaries.
# Write a message
$ export MESSAGE='Hello, World'
$ echo $MESSAGE
Hello, World
# Submit the message to the actor
$ tapis actors submit -m "$MESSAGE" w66kex1yD7Ql
+-------------+---------------+
| Field | Value |
+-------------+---------------+
| executionId | w1plap4NalAWb |
| msg | Hello, World |
+-------------+---------------+
The id of the actor (w66kex1yD7Ql) was used on the command line to specify
which actor should receive the message. In response, an “execution id”
(w1plap4NalAWb) is returned. An execution is a specific instance of an actor.
List all the executions for a given actor as:
$ tapis actors execs list w1plap4NalAWb
+---------------+----------+
| executionId | status |
+---------------+----------+
| w1plap4NalAWb | COMPLETE |
+---------------+----------+
The above execution has already completed. Show detailed information for the execution with:
$ tapis actors execs show -v w66kex1yD7Ql w1plap4NalAWb
{
"actorId": "w66kex1yD7Ql",
"apiServer": "https://api.sd2e.org",
"cpu": 559911564,
"exitCode": 0,
"finalState": {
"Dead": false,
"Error": "",
"ExitCode": 0,
"FinishedAt": "2021-08-24T14:33:48.879Z",
"OOMKilled": false,
"Paused": false,
"Pid": 0,
"Restarting": false,
"Running": false,
"StartedAt": "2021-08-24T14:33:47.049Z",
"Status": "exited"
},
"id": "w1plap4NalAWb",
"io": 7349,
"messageReceivedTime": "2021-08-24T14:33:45.714Z",
"runtime": 2,
"startTime": "2021-08-24T14:33:46.565Z",
"status": "COMPLETE",
"workerId": "E6LW3MrpyAOa",
"_links": {
"logs": "https://api.sd2e.org/actors/v2/w66kex1yD7Ql/executions/w1plap4NalAWb/logs",
"owner": "https://api.sd2e.org/profiles/v2/sgopal",
"self": "https://api.sd2e.org/actors/v2/w66kex1yD7Ql/executions/w1plap4NalAWb"
}
}
Check the Logs for an Execution¶
An execution’s logs will contain whatever was printed to STDOUT / STDERR by the actor. In our demo actor, we expect the actor to print the message passed to it, and email the message to the recipient email address we mentioned above.
$ tapis actors execs logs w66kex1yD7Ql w1plap4NalAWb
Logs for execution w1plap4NalAWb
Actor received message: Hello, World
Message emailed successfully!
Check your email for the message. Did you get it? Your actor just emailed you, Hooray!