-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
963 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Body Pose Invocation asynchronous invocation | ||
|
||
This example uses the pre-trained classification model by DEEP-Hybrid-DataCloud | ||
[Body Pose Detection](https://marketplace.deep-hybrid-datacloud.eu/modules/deep-oc-posenet-tf.html) | ||
and is prepared to be used with asynchronous invocations. | ||
|
||
|
||
In order to invoke the function, first you have to do is create a service, | ||
either by the OSCAR UI or by using the FDL within the following command. | ||
|
||
``` sh | ||
oscar-cli apply body-pose-detection-async.yaml | ||
``` | ||
|
||
Once the service is created you can make the invocation with the following | ||
command, which will store the output on a minio bucket. | ||
|
||
``` sh | ||
oscar-cli service put-file body-pose-detection-async minio images/001.jpg body-pose-detection-async/input/001.jpg | ||
``` | ||
|
14 changes: 14 additions & 0 deletions
14
examples/body-pose-detection/body-pose-detection-async.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
functions: | ||
oscar: | ||
- oscar-cluster: | ||
name: body-pose-detection-async | ||
memory: 2Gi | ||
cpu: '1.0' | ||
image: deephdc/deep-oc-posenet-tf | ||
script: script.sh | ||
input: | ||
- storage_provider: minio.default | ||
path: body-pose-detection-async/input | ||
output: | ||
- storage_provider: minio.default | ||
path: body-pose-detection-async/output |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
IMAGE_NAME=`basename "$INPUT_FILE_PATH"` | ||
OUTPUT_IMAGE="$TMP_OUTPUT_DIR/" | ||
|
||
deepaas-predict -i "$INPUT_FILE_PATH" -ct application/zip -o $OUTPUT_IMAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# COMPSS with OSCAR | ||
|
||
## Dockerfile | ||
|
||
The first step is the creation of the Docker image | ||
The Docker image has to start from an image allocated in the [compss profile at dockerhub](https://hub.docker.com/u/compss) | ||
with all the dependencies | ||
|
||
``` Docker | ||
FROM compss/compss:{version} | ||
``` | ||
|
||
Copy the program inside the Docker container: | ||
|
||
- C/C++ Applications should be the entire project folder (the compilation will create the binary in execution time) compss_build_app | ||
- Java Application, the `.jar` file should be copy | ||
- In Python Applications, introduce all the code | ||
|
||
## Script | ||
|
||
Create the name of the output file and save it into the `$OUTPUT_FILE` variable. | ||
|
||
``` bash | ||
FILE_NAME=`basename "$INPUT_FILE_PATH" | cut -f 1 -d '.'` | ||
OUTPUT_FILE="$TMP_OUTPUT_DIR/$FILE_NAME.txt" | ||
``` | ||
|
||
Some services receive a compressed file that needs to be uncompressed, while others require parsing the input file. Once the input is parsed, the ssh server needs to be initialized. | ||
|
||
``` bash | ||
/etc/init.d/ssh start | ||
``` | ||
|
||
Finally, run COMPSs. Select the command more appropriate according to your language program. | ||
C programs need to be built first with `compss_build_app increment`. | ||
Redirect the output to `$OUTPUT_FILE`. | ||
|
||
``` bash | ||
runcompss --pythonpath=$(pwd) --python_interpreter=python3 {path_to_the_python_program.py} {input_variables} > $OUTPUT_FILE | ||
runcompss --classpath={path_to_the_jar.jar} {in_java_folder/MainClass} {input_variables} > $OUTPUT_FILE | ||
runcompss --lang=c --project=./xml/templates/project.xml master/{name_program} {input_variables} > $OUTPUT_FILE | ||
``` | ||
|
||
### Output warning redirect | ||
|
||
When COMPSs starts the execution, a warning message will appear in the logs. | ||
This message can be ignored. `WARNING: COMPSs Properties file is null. Setting default values` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM compss/compss:latest | ||
COPY increment /opt/increment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Increment in C with COMPSS and OSCAR | ||
|
||
The source code can be found in [github](https://github.com/bsc-wdc/tutorial_apps/tree/stable/c/increment) | ||
This example works by introducing four numbers: the first is the number of times to increase the counters the other three are the counters. | ||
The return will be the three counters incremented by the first number. | ||
|
||
The first step in this example is to parse the input file and set the arguments: | ||
|
||
```bash | ||
file=$(cat $INPUT_FILE_PATH) | ||
incrementNumber=$(echo "$file" | cut -f 1 -d ';') | ||
counter1=$(echo "$file" | cut -f 2 -d ';') | ||
counter2=$(echo "$file" | cut -f 3 -d ';') | ||
counter3=$(echo "$file" | cut -f 4 -d ';') | ||
``` | ||
|
||
In C language, it is necessary to change the directory and compile the project in a run time: | ||
|
||
``` bash | ||
cd /opt/increment | ||
compss_build_app increment | ||
``` | ||
|
||
The compilation process will create a folder with the name `master`. | ||
This folder contains binary program: | ||
|
||
``` bash | ||
runcompss --lang=c --project=./xml/templates/project.xml master/increment $incrementNumber $counter1 $counter2 $counter3 > $OUTPUT_FILE | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
docker build -t ghcr.io/grycap/increment-compss-c . | ||
docker push ghcr.io/grycap/increment-compss-c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
This is the Readme for: | ||
Increment | ||
|
||
[Name]: Increment | ||
[Contact Person]: [email protected] | ||
[Access Level]: public | ||
[License Agreement]: Apache2 | ||
[Platform]: COMPSs | ||
|
||
[Body] | ||
== Description == | ||
Increment is an application that takes three different values and increases them a number of given times. The purpose of this application is to show parallelism between the different increments. | ||
|
||
== Execution instructions == | ||
Usage: | ||
runcompss --lang=c /home/compss/tutorial_apps/c/increment/master/increment <N> <initValue1> <initValue2> <initValue3> | ||
|
||
where: | ||
* - N: Number of times to increase the counters | ||
* - initValue1: Initial value for counter 1 | ||
* - initValue2: Initial value for counter 2 | ||
* - initValue3: Initial value for counter 3 | ||
|
||
|
||
== Execution Example == | ||
runcompss --lang=c /home/compss/tutorial_apps/c/increment/master/increment 10 1 2 3 | ||
|
||
|
||
== Build == | ||
compss_build_app increment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2002-2015 Barcelona Supercomputing Center (www.bsc.es) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include<iostream> | ||
#include<fstream> | ||
#include<string> | ||
#include"increment.h" | ||
|
||
|
||
void increment(file fileName) { | ||
std::cout << "INIT TASK" << std::endl; | ||
std::cout << "Param: " << fileName << std::endl; | ||
|
||
int value; | ||
// Read value | ||
std::ifstream fis(fileName); | ||
if (fis.is_open()) { | ||
if (fis >> value) { | ||
fis.close(); | ||
} else { | ||
std::cerr << "[ERROR] Unable to read final value" << std::endl; | ||
fis.close(); | ||
} | ||
fis.close(); | ||
} else { | ||
std::cerr << "[ERROR] Unable to open file" << std::endl; | ||
} | ||
|
||
// Increment | ||
std::cout << "INIT VALUE: " << value << std::endl; | ||
std::cout << "FINAL VALUE: " << ++value << std::endl; | ||
|
||
// Write new value | ||
std::ofstream fos (fileName); | ||
if (fos.is_open()) { | ||
fos << value << std::endl; | ||
fos.close(); | ||
} else { | ||
std::cerr << "[ERROR] Unable to open file" << std::endl; | ||
} | ||
std::cout << "END TASK" << std::endl; | ||
} |
Oops, something went wrong.