Projects

Project Quick Start

Working with Project class

You can work directly on project:

>>> from openalea.core.project import Project, get_project_dir
>>> from openalea.core.path import path
>>> # Real work on project:
>>> project_path = path(get_project_dir()) / 'project1'
>>> project1 = Project(project_path)
>>> project1.start()

Change metadata:

>>> project1.authors = "OpenAlea Consortium and John Doe"
>>> project1.description = "Test project concept with numpy"
>>> project1.long_description = ' '.join([
... 'This project import numpy. Then, it create and display a numpy eye.',
... 'We use it to test concept of Project.'])

... project file, models, ... :

>>> success = project1.add(category="model", filename="hello.py", content="print('Hello World')")
>>> project1.description = "This project is used to said hello to everyone"
>>> startup_obj = project1.add(category="startup", filename="begin_numpy.py", content="import numpy as np")
>>> model_obj = project1.add(category="model", filename="eye.py", content="print np.eye(2)")
>>> project1.rename_item("model", "eye.py", "eye_numpy.py")

At this time, project is only in memory. To write it on disk, just call "project1.save()"

Creation and Manipulation with Project Manager

Or, you can create or load a project thanks to the project manager.
>>> from openalea.core.project import ProjectManager
>>> project_manager = ProjectManager()
Discover available projects
>>> project_manager.discover()
>>> list_of_projects = project_manager.projects
Create project in default directory or in specific one
>>> p1 = project_manager.create('project1')
>>> p2 = project_manager.create(name='project2', projectdir=".")
Load project from default directory
>>> p3 = project_manager.load('sum')
Load project from a specific directory
>>> import openalea.oalab
>>> from openalea.deploy.shared_data import shared_data
>>> project_dir = shared_data(openalea.oalab)
>>> p4 = project_manager.load('sum', project_dir)
Load
>>> project2 = project_manager.load("sum")
Run startup
>>> project2.start()
Get model
>>> model = project2.get_model("sum_int")

Search other projects

To search projects that are not located inside default directories:
>>> project_manager.repositories.append('/path/to/search/projects') 
>>> project_manager.discover() 
>>> list_of_projects = project_manager.projects 

Project API

The Project is a structure which permits to manage different objects.

It stores metadata (alias, author, description, version, license, ...) and data (src, models, images, ...).

You have here the default architecture of the project saved in directory "project".

/project

oaproject.cfg (Configuration file) /model (Files sources, Script Python, LPy...) /control (Control, like color map or curve) /world (scene, scene 3D) /cache (Intermediary saved objects) /data (Data files like images, .dat, ...) /lib (Contains python modules and packages) /startup (Preprocessing scripts)

.py (Preprocessing scripts) *import.py (Libs and packages to import in preprocessing)
use:
project = Project(path="/path/to/proj/project")
project.add(category="model", filename="hello.py", content="print 'Hello World'")
project.author = "John Doe"
project.description = "This project is used to said hello to everyone"
project.save()

Table Of Contents

Previous topic

Plugins

Next topic

Models

This Page