Statistical Algorithms Importer: Python Project

From Gcube Wiki
Revision as of 16:04, 22 November 2018 by Giancarlo.panichi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This page explains how to create a Python project using the Statistical Algorithms Importer (SAI) portlet.Currently two types of projects can be created, one specific for version 3.6 and one generic one which is executed with version 2.7.
Python Project, SAI
Python 3.6 Project, SAI

Project Configuration

Define project's metadata
Python Info, SAI
Add input and output parameters and click on "Set Code" to indicate the main file to execute (i.e. the .py file)
Python I/O, SAI
Add information about the running environment (e.g. Python version etc.)
Python Interpreter, SAI
After the software creation phase a Main.R file and a Taget folder are created
Python Create, SAI

Example Code

Python code in sample:
#
# author Giancarlo Panichi
#
# HelloWorld
# 
import sys
 
for arg in sys.argv: 1
out_file = open("helloworld.txt","w")
out_file.write("Hello World\n"+arg+"\n")
out_file.close()

Example Download

File:PythonBlackBox.zip

Inheritance of Global and Infrastructure Variables

At each run of the process the globalvariables.csv file is created locally to the process (i.e. it can be read as ./globalvariables.csv), which contains the following global variables that are meant to allow the process to properly contact the e-Infrastructure services:

  • gcube_username (the user who run the computation, e.g. gianpaolo.coro)
  • gcube_context (the VRE the process was run in, e.g. d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab)
  • gcube_token (the token of the user for the VRE, e.g. 1234-567-890)

The format of the CSV file is like the one of the following example:

globalvariable,globalvalue
gcube_username,gianpaolo.coro
gcube_context,/d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab
gcube_token,1234-567-890