# Add an application on NooLib

##### Catégorie : Informatique
Submit an application on NooLib is quite easy but it requires some specific information for the developer. Currently, you can deposit your own algorithms written in JS, PHP, Matlab, Python2, Python3 or Java.

For Java programs, you must upload a jar file and it is not currently possible to modify the Java program directly on NooLib whereas it can be done with other programming languages. For Matlab programs, you need a valid license. We update regularly the features of the platform and we invite you to contribute to the development of the platform if you have specific needs. Please, do not hesitate to contact us.

Please note that you must not include any graphic components in your programs. The graphic components are already taken into account by NooLib.

# 1. An overview

Each application on the platform is divided into tasks. Each task is divided into functions and each function is divided into parameters.

A task allows a specific processing and it can request one or more data as input. A function is a script written in a specific programming language (JS, PHP, Python3, etc.). When a task regroups more than one function, the output of the previous function is the input of the next function. The output of the last function called by the task becomes the response sent to the client. Finally, each function can own one or more parameters. Each parameter can be adjusted by the user before running a task of an application. The parameter can be displayed as a public parameter (edited by the user) or as a private parameter (edited by the developer only).

The architecture presented here defines the tree of the application.

Figure 1. Tree of an application owning 3 tasks.

# 2. The inputs

For a function, inputs can be of three kinds:

• data dragged and dropped by the user in the data box of the application before running,

• the parameters of the function which can be edited by the user/developer,

• the output of the last function called by the task.

Data are managed by the user using his data manager available in the NooSpace. Currently, data can be a text file, a CSV file, an EDF file, an image or a string edited by the user. However, text files and EDF files are automatically transformed into CSV files by NooLib. In CSV files, adjacent fields are separated by a single comma and no field are quoted (that is, enclosed within double-quote characters).

Example of a CSV file:
One,Two,Three
342.23,9.33,43.32
21,32.3,1
3.3,21.3,23.1


Notice that data types may evolve as the NooLib platform evolves. Stay tuned!

Each task of an application can receive one or more data and these one are transferred to each function called by the task. For the developer, data are reachable by their url link. For example, in Python3, if we consider that a task requests 3 data and the second function have 2 parameters then, for this function, you can recover all the arguments according to:

# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# Function 2
import sys
import json
import csv
url_data_1 = sys.argv[1] # url of the first data dropped in the data box - this is a CSV file
url_data_2 = sys.argv[2] # url of the second data dropped in the data box - this an image
url_data_3 = sys.argv[3] # url of the third data dropped in the data box - this a string
parameter1 = float(sys.argv[4]) # Parameter 1 of function 2
parameter2 = float(sys.argv[5]) # Parameter 2 of function 2
output = json.loads(sys.argv[6]) # Output of function 1
#...
with open(url_data_1, newline='') as f:
legend = next(reader)  # The caption of a CSV file is contained in the first line
#...


Notice that the first line of a CSV file always contains the caption of the table. This is automatically added by the data manager of NooLib. So, be careful to remove this line before processing data.

# 3. Communication between functions

You can communicate between functions by sending their results in text format. Do not use JSON format whether the ouput will not be interpreted as an argument in the shell execution.
In the example below, the function 1 sends an associative table to the next function.
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# Function 1
#...
countElement = 100
sumData = 2017
# Do not insert any space in the text output
output = '{"sizeData":'+str(countElement)+',"sumData":'+str(sumData)+'}' # Output = input for the next function
print(output)


# 4. The response

The last function called by a task defines the response which will be sent to the client. The response must be in JSON format and must respect a programming nomenclature according to:

{
"graphs":[
{
"data":[
[
2.0,
3.0
],
[
4.0,
5.0
]
],
"legend":[
"randomTitle",
"randomTitle2"
],
"sampleRate":1,
"name":"Graph 1"
},
{
"data":[
[
2.0,
3.0
],
[
4.0,
5.0
]
],
"legend":[
"randomTitle",
"randomTitle2"
],
"sampleRate":1,
"name":"Graph 2"
}
],
"files":[
{
"data":"IjQuMCIsIjUuMCIiNC4wIiwiNS4wIg==",
"name":"MyFileCsv",
"ext":"csv"
},
{
"data":"IjQuMCIsIjUuMCIiNC4wIiwiNS4wIg==",
"name":"MyFileCsvCopy",
"ext":"csv"
}
],
"images":[
{
"data":"77+9UE5HGgAAAElIRFIAAAABAAAAAQAAAABd77+9Ce+/vQAAAAtJREFUeO+/vWNg77+9BAAAFAAB77+9WmkJAAAAAElFTkTvv71CYO+/vQ==",
"name":"MyImage",
"ext":"png"
},
{
"data":"77+9UE5HGgAAAElIRFIAAAABAAAAAQAAAABd77+9Ce+/vQAAAAtJREFUeO+/vWNg77+9BAAAFAAB77+9WmkJAAAAAElFTkTvv71CYO+/vQ==",
"name":"MyImageCopy",
"ext":"png"
}
],
"results":[
{
"name":"This result is very important",
"value":"42.0",
"min":"-1.0",
"max":"-1.0",
"thresholdMin":"-1.0",
"thresholdMax":"-1.0",
"unit":"pts"
},
{
"name":"Another result",
"value":"This result is not very important",
},
{
"name":"A result with max min and thresholds",
"value":"6.0",
"min":"5.0",
"max":"55.0",
"thresholdMin":"18.5",
"thresholdMax":"25.0",
"unit":"Hz"
},
{
"name":"Execution time",
"value":"3313.0",
"min":"-1.0",
"max":"-1.0",
"thresholdMin":"-1.0",
"thresholdMax":"-1.0",
"unit":"ms"
}
],
{
"name":"Title 1",
"content":"This is a small information about my program"
},
{
"name":"Title 2",
"content":"Another information"
}
],
"errors":[
{
"name":"Type 1",
"content":"An error has occured while copying."
},
{
"name":"Type 2",
"content":"Another error has occured. Please, be careful."
}
]
}


"Graphs" represents a table of graphs where you can find for each of them:

• data grouped into series,

• a legend representing the name of each serie,

• the sampling rate of the data,

• the name of the graph.

"Images" (resp. "Files") represents a table of images (resp. a table of files). Notice that data of images/files must be encoded in base 64 (UTF-8).
"Results" represents a table of results. Each result can be described by a name and a value. You can also add a minimum value, a maximum value and two thresholds to display the result as a gauge.

For example, in Python3:


# Create the response to the client
response = [{
"results":[
{   "name":"Mean",
"value": str(mean),
"min":"-10.0",
"max":"10.0",
"thresholdMin":"-0.5",
"thresholdMax":"0.5",
"unit":"Hz"
},
{   "name":"Sum of element",
"value": str(sumData)

},
{   "name":"Size data",
"value": str(sizeData)

},
{   "name":"Multiplicator",
"value": str(multiplicator)

}
],
}]
print(json.dumps(output)) # The output is in JSON format


Notice that if you do not enter a minimum or a maximum value, the result will be displayed as a table otherwise it will be displayed as a gauge. If you do not enter the both thresholds, the gauge will be displayed in an unique color.

A demonstration application is available in your application manager once you have completed your registration. You will find some examples of what you can do.

# 5. Submit an application

To submit of an application, go to the Submit page. The proceeding is performed according to 3 steps.

### Step 1

Here, you must fill in the name of your application, a short description of what your application can do and a category for a search engine optimization. You can also enter a hyperlink if you want to promote your application on another website.

### Step 2

The second step requires at least one keyword and an icon of your application. You can find a free icon on Icon Finder website. Please make sure that the picture is in PNG format and has a resolution of 128*128px.

### Step 3

The final step asks for scientific articles that validate your algorithms. You can add one or more publications. Do not hesitate to use the DOI format for a better integration of your article. If you have no publication released yet, just click on the blue button to validate your submission.

Once you have confirmed the last step, you will move automatically to the tree of the application.

Notice that all information entered during the proceeding could be changed later in the tree of the application.

If you abandon the proceeding before completing the last step, you have the opportunity to resume it by clicking on the application in your application manager.

# 6. The tree of an application

The tree of an application represents the architecture of this application. A quick tour using the help button will give you the main features of your application.

Figure 2. The tree of the demonstration application.

To start creating the tree of your application, you need to add a task by clicking on the "New task" button. You must enter a name for the task and a short description. You also need to add one or more data which will represent data dragged and dropped by the user into the data box of the application.
Once a task is created, you can add one or more functions for this task and add one or more parameters for each function created.

Be careful, if two or more functions are assigned to a task, you need to make sure that the output of a function matches the input of the next function.

# 7. Libraries for developers

### A Java Library

On GitHub, you will find a Java Library to generate automatically the response of your application.
Thanks to Quentin Denis for his contribution.

### Others libraries

Please stay tuned... others libraries will be created for others programming languages.