added example for access workspace with bash

This commit is contained in:
dcore94 2024-04-09 15:04:21 +02:00
parent c051bbe637
commit feebaf1ea0
6 changed files with 52 additions and 11 deletions

Binary file not shown.

View File

@ -334,6 +334,20 @@ As an example the following Python code shows how to use the variables to reques
# List VRE fodler content
vrefolder = requests.get(workspace + "/vrefolder", headers={"Accept" : "application/json", "Authorization" : "Bearer " + tok}).json()
An similar example in bash could have the following form:
.. code-block:: bash
:caption: How to download a file from the D4Science workspace from a private URL passed as input parameter
echo "Getting token"
TOKEN=$(curl -X POST $ccpiamurl -d grant_type=refresh_token -d client_id=$ccpclientid -d refresh_token=$ccprefreshtoken -H "X-D4Science-Context: $ccpcontext" | jq -r '."access_token"')
echo Downloading $1 to $2
curl -L $wslink -o $inputfile -H "Authorization: Bearer $TOKEN"
echo "Downloaded"
A special folder is provided in the Runtime to a Method execution for storing output files. Files are currently the only way for a Method to output results by value. The folder is named **/ccp_data** and all the files written to this folder are returned in the context of the Execution as a zip archive.
Executions

File diff suppressed because one or more lines are too long

View File

@ -398,6 +398,19 @@ The technology and the list of available Runtimes is strictly related to type of
</pre></div>
</div>
</div>
<p>An similar example in bash could have the following form:</p>
<div class="literal-block-wrapper docutils container" id="id4">
<div class="code-block-caption"><span class="caption-text">How to download a file from the D4Science workspace from a private URL passed as input parameter</span><a class="headerlink" href="#id4" title="Permalink to this code"></a></div>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="nb">echo</span><span class="w"> </span><span class="s2">&quot;Getting token&quot;</span>
<span class="w"> </span><span class="nv">TOKEN</span><span class="o">=</span><span class="k">$(</span>curl<span class="w"> </span>-X<span class="w"> </span>POST<span class="w"> </span><span class="nv">$ccpiamurl</span><span class="w"> </span>-d<span class="w"> </span><span class="nv">grant_type</span><span class="o">=</span>refresh_token<span class="w"> </span>-d<span class="w"> </span><span class="nv">client_id</span><span class="o">=</span><span class="nv">$ccpclientid</span><span class="w"> </span>-d<span class="w"> </span><span class="nv">refresh_token</span><span class="o">=</span><span class="nv">$ccprefreshtoken</span><span class="w"> </span>-H<span class="w"> </span><span class="s2">&quot;X-D4Science-Context: </span><span class="nv">$ccpcontext</span><span class="s2">&quot;</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>jq<span class="w"> </span>-r<span class="w"> </span><span class="s1">&#39;.&quot;access_token&quot;&#39;</span><span class="k">)</span>
<span class="w"> </span><span class="nb">echo</span><span class="w"> </span>Downloading<span class="w"> </span><span class="nv">$1</span><span class="w"> </span>to<span class="w"> </span><span class="nv">$2</span>
<span class="w"> </span>curl<span class="w"> </span>-L<span class="w"> </span><span class="nv">$wslink</span><span class="w"> </span>-o<span class="w"> </span><span class="nv">$inputfile</span><span class="w"> </span>-H<span class="w"> </span><span class="s2">&quot;Authorization: Bearer </span><span class="nv">$TOKEN</span><span class="s2">&quot;</span>
<span class="w"> </span><span class="nb">echo</span><span class="w"> </span><span class="s2">&quot;Downloaded&quot;</span>
</pre></div>
</div>
</div>
<p>A special folder is provided in the Runtime to a Method execution for storing output files. Files are currently the only way for a Method to output results by value. The folder is named <strong>/ccp_data</strong> and all the files written to this folder are returned in the context of the Execution as a zip archive.</p>
</section>
</section>
@ -445,10 +458,10 @@ The following is a representation of the data structure representing an Executio
<h3>Method list<a class="headerlink" href="#method-list" title="Permalink to this heading"></a></h3>
<p>The <em>Method list</em> widget is a visual representantion of the list of Methods that a user is able to access in a given context either because he/she is the owner or because they are shared in the context.</p>
<p>The following Figure shows an example visualization of the Method list.</p>
<figure class="align-default" id="id4">
<figure class="align-default" id="id5">
<img alt="Method list widget" src="../_images/methodlistwidget.png" />
<figcaption>
<p><span class="caption-text">Method list widget</span><a class="headerlink" href="#id4" title="Permalink to this image"></a></p>
<p><span class="caption-text">Method list widget</span><a class="headerlink" href="#id5" title="Permalink to this image"></a></p>
</figcaption>
</figure>
<p>The Method list widget is comprised of a toolbar, a search field and the list of Methods. The Methods are organized by categories as shown in [1]. For every Method the title, version, author and description are reported in the first two lines [2]. As additional information tags and compatible Infrastructure are shown [3]. There is the possibility to download a Method or a whole class and to see how many of the shown Methods are executable [4]. Methods can be not executable if their compatible Infrastrucure is not known or available. A per MEthod tollbar [5] allows to download, edit or execute a Method for. From the global toolbar it is possible to refresh the list or upload a Method from a file [6] and also to reimport an archived Method from the workspace by copying and pasting the shareable link into the proper field and clicking on the button [7].</p>
@ -457,10 +470,10 @@ The following is a representation of the data structure representing an Executio
<h3>Method editor<a class="headerlink" href="#method-editor" title="Permalink to this heading"></a></h3>
<p>The <em>Method editor</em> widget is a visual tool for creating, deleting, editing, cloning or deriving a Method descriptor.</p>
<p>The following Figure shows an example visualization of the Method editor.</p>
<figure class="align-default" id="id5">
<figure class="align-default" id="id6">
<img alt="Method editor widget" src="../_images/methodeditorwidget.png" />
<figcaption>
<p><span class="caption-text">Method editor widget</span><a class="headerlink" href="#id5" title="Permalink to this image"></a></p>
<p><span class="caption-text">Method editor widget</span><a class="headerlink" href="#id6" title="Permalink to this image"></a></p>
</figcaption>
</figure>
<p>From the global toolbar [1] it is possible to save the edited Method or delete it or clear all the form fields. The metadata area [2] contains the controls to define all the metadata of a Method including title, version, description, tags, categories. It is also possible to choose a compatible Infrastructure from the available ones. In the input definition area [3] the user can define all the input parameters with their type, format, encoding, cardinality and default values. In the output definition area [4] the user can define all the output files that can be expected from an Execution with their type, format, encoding and cardinality. Shortcuts are added to define with one click the standard output and error chnannels of a Method. In the scripting area [5] the deploy, execute and undeploy script can be defined.</p>
@ -470,10 +483,10 @@ The following is a representation of the data structure representing an Executio
<h3>Method execution form<a class="headerlink" href="#method-execution-form" title="Permalink to this heading"></a></h3>
<p>The <em>Method execution form</em> widget is a visual tool for requesting the execution of a Method.</p>
<p>The following Figure shows an example visualization of the Method execution form.</p>
<figure class="align-default" id="id6">
<figure class="align-default" id="id7">
<img alt="Method execution form" src="../_images/executionformwidget.png" />
<figcaption>
<p><span class="caption-text">Method execution form</span><a class="headerlink" href="#id6" title="Permalink to this image"></a></p>
<p><span class="caption-text">Method execution form</span><a class="headerlink" href="#id7" title="Permalink to this image"></a></p>
</figcaption>
</figure>
<p>In the area labelled with [1], the principal metadata of the Method is shown. In the Inputs area [2] it is possible to edit the input values that are passed to the Execution. The input fields try to match as close as possible the constraints defined for the input in the Method descriptor. The execute button [4] triggers the sending of the execution request. A code generator widget [5] can be used in order to download code snippets that act as working examples for requesting the Execution programmatically through the CCP APIs (see <a class="reference internal" href="#rest"><span class="std std-ref">REST APIs: Interacting with Methods and Executions programmatically</span></a>). Currently Python 3, R, Jupyter Notebook and Julia are supported but the list will grow in the future.</p>
@ -483,10 +496,10 @@ The following is a representation of the data structure representing an Executio
<h3>Execution monitor<a class="headerlink" href="#execution-monitor" title="Permalink to this heading"></a></h3>
<p>The <em>Execution Monitor</em> widget is a visual tool for monitoring Executions.</p>
<p>The following Figure shows an example visualization of the Execution monitor.</p>
<figure class="align-default" id="id7">
<figure class="align-default" id="id8">
<img alt="Execution monitor" src="../_images/executionmonitorwidget.png" />
<figcaption>
<p><span class="caption-text">Execution monitor</span><a class="headerlink" href="#id7" title="Permalink to this image"></a></p>
<p><span class="caption-text">Execution monitor</span><a class="headerlink" href="#id8" title="Permalink to this image"></a></p>
</figcaption>
</figure>
<p>The list of Executions are organized by their Method names [1]. For every Method the number of executions in the different states (accepted, running, successful, failed) is reported. When expanding a Method the list of all Executions is shown [2]. Every list item reports information about the Method version, the status, timing, Infrastructure and Runtime of the Execution. When outputs are available a link to download them is shown [3]. Actions that can be performed on an Execution [5] are download as zip archive, archive to workspace, download provenance descriptor in Prov-O format, re-execute and delete. An Execution item can also be drag and dropped onto the Execution form widget in order to prepare a request for a new onne. Code for programmatically requesting the same Execution can be generated with a proper code generation widget [6]. Currently Python 3, R, Julia and Jupyter Notebooks are currently supported.</p>
@ -502,8 +515,8 @@ The REST API is Processes 1.2 described at (<a class="reference external" href="
<p>The CCP REST API is documented as OpenAPI 3 specification at (<a class="reference external" href="https://app.swaggerhub.com/apis/OGC/ogcapi-processes-1-example-1/1.0.0">https://app.swaggerhub.com/apis/OGC/ogcapi-processes-1-example-1/1.0.0</a>).</p>
<p>Through the code generation widgets available in the UI elements described above, it is possible to obtain stubs that show how to interact programmatically with CCP in order to request a Method execution or re-execution and to monitor the evolution.</p>
<p>The following is an example code stub generated for the R programming language.</p>
<div class="literal-block-wrapper docutils container" id="id8">
<div class="code-block-caption"><span class="caption-text">Example code for requesting a Method execution on CCP</span><a class="headerlink" href="#id8" title="Permalink to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id9">
<div class="code-block-caption"><span class="caption-text">Example code for requesting a Method execution on CCP</span><a class="headerlink" href="#id9" title="Permalink to this code"></a></div>
<div class="highlight-R notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Dependencies</span>
<span class="w"> </span><span class="nf">library</span><span class="p">(</span><span class="n">httr</span><span class="p">)</span>
<span class="w"> </span><span class="nf">library</span><span class="p">(</span><span class="n">jsonlite</span><span class="p">)</span>

View File

@ -334,6 +334,20 @@ As an example the following Python code shows how to use the variables to reques
# List VRE fodler content
vrefolder = requests.get(workspace + "/vrefolder", headers={"Accept" : "application/json", "Authorization" : "Bearer " + tok}).json()
An similar example in bash could have the following form:
.. code-block:: bash
:caption: How to download a file from the D4Science workspace from a private URL passed as input parameter
echo "Getting token"
TOKEN=$(curl -X POST $ccpiamurl -d grant_type=refresh_token -d client_id=$ccpclientid -d refresh_token=$ccprefreshtoken -H "X-D4Science-Context: $ccpcontext" | jq -r '."access_token"')
echo Downloading $1 to $2
curl -L $wslink -o $inputfile -H "Authorization: Bearer $TOKEN"
echo "Downloaded"
A special folder is provided in the Runtime to a Method execution for storing output files. Files are currently the only way for a Method to output results by value. The folder is named **/ccp_data** and all the files written to this folder are returned in the context of the Execution as a zip archive.
Executions