INCATools / ontology-development-kit

Bootstrap an OBO Library ontology
http://incatools.github.io/ontology-development-kit/
BSD 3-Clause "New" or "Revised" License
212 stars 53 forks source link

ROBOT custom plugins issue from within make and outside make #1045

Closed matentzn closed 2 months ago

matentzn commented 2 months ago

I just observed this oddity, and am wondering if you can see @gouttegd and easy explanation:

If I run a robot command with a plugin directly from the command line:

 ontology git:(upheno-refactor) sh run.sh robot merge -i phenio.owl upheno:extract-upheno-relations --root-phenotype UPHENO:0001001 --relation UPHENO:0000003 --relation UPHENO:0000001 -o phenio_test.owl

I get this error:

Running obolibrary/odkfull:latest with '-Xmx30G' as options for ROBOT and other Java-based pipeline steps.
UNKNOWN ARG ERROR unknown command or option: upheno:extract-upheno-relations
For details see: http://robot.obolibrary.org/errors#unknown-arg-error
Use the -vvv option to show the stack trace.
Use the --help option to see usage information.
usage: robot [command] [options] <arguments>
    --add-prefix <arg>      add prefix 'foo: http://bar' to the output
    --add-prefixes <arg>    add JSON-LD prefixes to the output
    --catalog <arg>         use catalog from provided file
 -h,--help                  print usage information
    --noprefixes            do not use default prefixes
 -p,--prefix <arg>          add a prefix 'foo: http://bar'
 -P,--prefixes <arg>        use prefixes from JSON-LD file
    --strict                use strict parsing when loading an ontology
 -V,--version               print version information
 -v,--verbose               increased logging
 -vv,--very-verbose         high logging
 -vvv,--very-very-verbose   maximum logging, including stack traces
 -x,--xml-entities          use entity substitution with ontology XML
                            output
commands:
 help             print help for command
 annotate         annotate ontology
 collapse         minimize an ontology based on a threshold
 convert          convert ontology
 diff             find the differences between two ontologies
 expand           expand ontology
 explain          explain derivation of an inferred axiom
 export           export ontology as a table
 export-prefixes  export prefixes to a file
 extract          extract terms from an ontology
 filter           filter ontology axioms
 materialize      materialize ontology
 measure          compute the metrics of an ontology
 merge            merge ontologies
 mirror           mirror ontology imports closure
 python           start a server to run ROBOT with Py4J
 query            query an ontology
 reason           reason ontology
 reduce           reduce ontology
 relax            relax ontology
 remove           remove axioms from an ontology
 rename           rename entities based on given mappings
 repair           repair terms from an ontology
 report           report terms from an ontology
 template         build an ontology from a template
 unmerge          unmerge ontologies
 validate-profile validate ontology against an OWL profile
 verify           verify an ontology does not violate rules (as queries)
Command exited with non-zero status 1
### DEBUG STATS ###
Elapsed time: 0:00.29
Peak memory: 127148 kb

If I stick it into the Makefile:

tmp/phenio-fast.owl: 
    $(ROBOT) merge -i phenio.owl upheno:extract-upheno-relations --root-phenotype UPHENO:0001001 --relation UPHENO:0000003 --relation UPHENO:0000001 -o phenio_test.owl

I get:

➜  ontology git:(upheno-refactor) ✗ sh run.sh make tmp/phenio-fast.owl
Running obolibrary/odkfull:latest with '-Xmx30G' as options for ROBOT and other Java-based pipeline steps.
robot --catalog catalog-v001.xml merge -i phenio.owl upheno:extract-upheno-relations --root-phenotype UPHENO:0001001 --relation UPHENO:0000003 --relation UPHENO:0000001 -o phenio_test.owl

Can you imagine any good explanation for this?

gouttegd commented 2 months ago

That’s completely expected. If you invoke ROBOT directly, it has no idea where to look for plugins. So it looks in the default location, $HOME/.robot/plugins, where obviously it does not find anything.

When you invoke it as part of a Makefile rule, it knows to look into $(ROBOT_PLUGINS_DIRECTORY) (aka $(TMPDIR)/plugins) because the Makefile explicitly sets and exports the ROBOT_PLUGINS_DIRECTORY variable.

There is no mechanism to pass arbitrary environment variables to run.sh, so what you could do here instead is to use ODK_JAVA_OPTS to set the robot.pluginsdir Java property:

ODK_JAVA_OPTS="-Drobot.pluginsdir=/work/src/ontology/tmp/plugins" sh run.sh robot ...

Of note:

matentzn commented 2 months ago

Perfect! Thank you!!