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()"
>>> from openalea.core.project import ProjectManager
>>> project_manager = ProjectManager()
>>> project_manager.discover()
>>> list_of_projects = project_manager.projects
>>> p1 = project_manager.create('project1')
>>> p2 = project_manager.create(name='project2', projectdir=".")
>>> p3 = project_manager.load('sum')
>>> import openalea.oalab
>>> from openalea.deploy.shared_data import shared_data
>>> project_dir = shared_data(openalea.oalab)
>>> p4 = project_manager.load('sum', project_dir)
>>> project2 = project_manager.load("sum")
>>> project2.start()
>>> model = project2.get_model("sum_int")
>>> project_manager.repositories.append('/path/to/search/projects')
>>> project_manager.discover()
>>> list_of_projects = project_manager.projects
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()
|
---|