One more thing to do with the plugin interface that I'd like to ask questions about before release. It might just be a case of clarifying things so that I can write the documentation accurately; it might mean a small last-minute adjustment to how Avogadro handles things.
Plugins are currently able to pass back to Avogadro, as part of the output JSON object, two key/value pairs that should have a similar effect:
"append": true"readProperties": true
Both are by default false if not specified.
The default behaviour of Avogadro for a menuCommand is to replace the entire contents of the current file with whatever the plugin sends back. If the file/geometry that the plugin sends back is not a CJSON, Avogadro first converts the returned format into CJSON. Thus if a plugin sends nothing back, the current molecule/file disappears. For this reason, some commands in the xtb plugin take care to send back the entire input CJSON with zero changes, because the commands only do something like open a URL in the web browser.
I believe both append and readProperties are meant to indicate to Avogadro something like "don't discard the current file, don't replace it with what I am giving you, just supplement the current file with whatever I am giving you".
IIRC I found them to be either unreliable, unpredictable, or not quite appropriate for what I needed when writing the xtb plugin, and so instead opted to have the plugin handle merging and dropping data as appropriate.
Which of those reasons it was, I can no longer remember. But ideally future plugin authors wouldn't have to do that kind of manual adjustment.
In any case, I'd like to properly document both and define their purpose so that it's clear in future what is buggy behaviour and what is intended.
Is my understanding of their effect roughly correct? What are they actually meant to do?
What is the distinction between
appendandreadProperties?Are they only valid keys for
menuCommand?Would they not be better off being indicated in the TOML metadata? That's where the plugin now indicates what output Avogadro should expect, so wouldn't it make sense to also indicate there what Avogadro should do with said output?
Do we want to take the opportunity to adjust the defined intended behaviour at all, or does it make sense in both cases already?
Discuss this on our forum.
Thanks for the explanations! To be clear, this is not something I’m champing at the bit to change or anything, it’s just an aspect that I’d had had on my to-do list but had never raised.
I had the idea in my head somehow that the two were more similar than they are and were somehow duplicating each other. That’s clearly not the case.
Sorry, I meant “converting to Avogadro’s in-memory representation”, which I tend to think of as equivalent to CJSON, because both can usually represent the same information – even though of course they are not actually the same thing.
For further clarification (and this is all so that I can write clear documentation, not just to be annoying):
What happens if
appendis used and the original file contains properties, e.g. frequencies? Are they discarded?What happens if
appendis used when the file being passed back contains properties? Presumably the properties don’t get appended too? They’re just ignored?What happens if
readPropertiesis used and the original file already has some property information? Are all the original properties discarded? Or are they kept unless the plugin passes replacement values?What happens if a plugin tries to use
appendandreadPropertiesat the same time?Unfortunately, I can’t exactly remember. Which I know is not helpful.
I have a vague notion that it might have been that the answer to (8) was “all the existing properties are discarded”? Because that would have had consequences for the xtb plugin – it means that if a user first calculated frequencies and then requested the MOs the frequencies would vanish.
core/molecule.cpp)readPropertiesI mean, it’s always better (more precise) if you have the
cjsonrepresentation to make any specific changes you want. The main point forappendandreadPropertiesis to make it easier for plugin authors to do various things.It’s much easier to use
appendto implement various “Build” tools because you just add the atoms and bonds to the scene.