Skip to content

Conversation

@Money-eng
Copy link
Contributor

  • Correcting methods root and functions (Dumper class)
  • Adding observation_hours property in metadata if accessible
  • If the time, time_hours or diameter are loaded as graph_properties but not defined as functions in metadata, we add them

This has only been tested on RSMLs issued by RootSystemTracker.

@pradal pradal self-requested a review November 13, 2025 20:29

# if some functions are defined in the MTG properties but not in metadata, add them
graph = self._g
if graph.graph_properties().get('metadata', {}).get('functions') is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get just ones graph_properties rather than calling each time.
Code will be simpler, nicer.

props = graph.graph_properties()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or directly for metadata

metadata = graph.graph_properties().set_default('metadata', {})

graph = self._g
if graph.graph_properties().get('metadata', {}).get('functions') is None:
graph.graph_properties()['metadata']['functions'] = []
if graph.properties().get('time'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

props is a dict, isn't it?

Just do

if 'time' in props:

for tag in pname:
if tag in props:
if functions_elt is None:
functions_elt = self.SubElement(xml_elt, 'functions')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

function_elt.attrib['name'] = tag

for sample in attrib[tag]:
for sample in props[tag]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep.

except OSError: # no such file
pass


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not...
Security flaw but ... we do not care

# table of observation times
obs = metadata['observation-hours']
if isinstance(obs, str):
import ast
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import at the begining of the file with ... imports

@pradal pradal merged commit 7f10b20 into openalea:hirros Dec 10, 2025
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants