Home | Download/Install | Documentation | Packages | Screenshots | News | Forum/Mailing-lists | Contact | GForge

How to manage shared data in an OpenAlea Package

Introduction

This tutorial describes how to manage data in a Python package.

Before starting, ensure you have a working development environment.

If you want to start directly with a real example, download the starter package.

How to manage data stored in a shared data directory

Add a shared data directory to your package

For example, to add a shared data directory to the alinea.echap package:

  1. open a shell, go to the root directory of the alinea.echap source tree, and create the share data directory:
    mkdir -p src/alinea/echap/share/data
  2. move your data directory to this shared directory:
    mv your_data_directory src/alinea/echap/share/data
  3. modify the setup.py:
    share_dirs = {os.path.join(*('alinea', 'echap', 'share')): os.path.join(*('src', 'alinea', 'echap', 'share'))}
  4. (re)install alinea.echap:
    python setup.py install

Access to these data files from Python interpreter

For example, to access the shared data file Mercia_axeT.csv of alinea.echap package:

import alinea.echap
from openalea.deploy.shared_data import shared_data
data_filepath = shared_data(alinea.echap, 'Mercia_axeT.csv')
data_files = shared_data(alinea.echap, pattern='*.csv') # return a list

See openalea.deploy.shared_data.get_shared_data_path documentation for other possibilities.

Access to these data files from Visualea

The node SharedDataBrowser is used to select a data file.

See openalea.misc_wralea.shared_data documentation for more details.

Here is a dataflow example using this node:

This dataflow can be found at openalea.misc.test.shared_data_browser

How to manage data stored as a Visualea Data File node

Import data from file

  1. Select Package Manager ⇒ Add ⇒ Data File
  2. Fill the form:
    • Package : the package where the Data File node is stored ; e.g. alinea.adel.data
    • File : path to your data file ; e.g. /home/user/openaleapkg/adel/adel/data/adel_input.csv
    • Decription : the description displayed in the help view when the Data File node is selected ; e.g. adel input data example
  3. Click “OK”

Access to these data files from Python interpreter

For example, to access the shared data file filterT.can of alinea.caribu.data package:

from openalea.core.system import systemnodes
data = systemnodes.get_data('filterT.can', 'alinea.caribu.data')
data_filepath = data.get('filterT.can')

See openalea.core.system.systemnodes.get_data documentation for other possibilities.

Access to these data files from Visualea

The node get_data is used to select a data file.

See openalea.datafile.datafile.GetData documentation for more details.

For example, the previous state of the Tutorial composite node of the alinea.caribu package was:

Using the get_data node makes the selection of a data file easier:

 
documentation/package/how_to_manage_data.txt · Last modified: 2014/03/03 19:21 by user   Back to top
INRIA   INRA     CIRAD     AGROPOLIS
INRIA GForge RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki