FEATURE AVAILABILITY STARTING FROM RELEASE 2.8.2
Introduction
JS7 offers a number of JS7 - Job Classes for Shell Jobs and JVM Jobs.
- Users can implement jobs using Python from JS7 - Shell Jobs.
- Users can implement jobs using Python from JS7 - GraalVM Jobs
GraalVM Jobs can be executed with any supported Java Virtual Machine (Oracle, OpenJDK). This allows use of the Oracle® GraalVM but does not require this flavor of the JVM.
- The Oracle® GraalVM implements Python 3.x depending on the version of the GraalVM Polyglot interface and Graal compiler in use.
- For details how to bring Polyglot and Graal Compiler to JS7 Agents see JS7 - Adding and Updating Graal Libraries to Agents.
- The Oracle® GraalVM can similarly be used for JS7 - GraalVM JavaScript Jobs.
JS7 offers the JS7 - Job API to GraalVM Jobs that serves the purpose of
- accessing arguments available to the job from various sources such as JS7 - Order Variables, job and node arguments, JS7 - Job Resources,
- allowing to specify the outcome of a job including return values that are passed to subsequent jobs from order variables.
Users should review the JS7 - GraalVM Run-time Options, which define the security of the run-time environment, and the extension of standard modules as outlined in JS7 - How to add modules to GraalVM Python Jobs.
Implementation
Implementing a basic Job
A Python Job is implemented by a class with the name JS7Job like this:
class JS7Job(js7.Job):
def processOrder(self, js7Step):
js7Step.getLogger().info("hello world")
# do some stuff
Explanation:
- The implementation class with the name JS7Job is required.
- The processOrder() method is required to be implemented by the job.
- The method is parameterized by the js7Step object provided by the Job API.
- The js7Step object is used with its getLogger() method to write output to the job's log.
Accessing Arguments
A Python Job can access arguments from a number of sources, see JS7 - Job API.
- The straightforward way how to read arguments is explained from the next chapter.
- For more detailed access methods and examples see JS7 - How to read arguments in GraalVM Python Jobs
class JS7Job(js7.Job):
def processOrder(self, js7Step):
logger = js7Step.getLogger()
# access argument by name
logger.info("[getAllArgumentsAsNameValueMap] by name:")
color_blue = js7Step.getAllArgumentsAsNameValueMap()["color_blue"]
logger.info(f"argument color_blue={color_blue}")
Explanation:
- The
getAllArgumentsAsNameValueMap()method provides a map of all arguments as a simplename-valuemap. The map allows to read a single argument from the argument name. - For further methods to access arguments see JS7 - Job API.
class JS7Job(js7.Job):
def processOrder(self, js7Step):
# get map of all arguments
args = js7Step.getAllArguments()
js7Step.getLogger().info("[getAllArguments]:")
js7Step.getLogger().info(f"all arguments: {args}")
for arg_name, arg in args.items():
js7Step.getLogger().info(f"argument: {arg_name}={arg.getValue()}")
Explanation:
- The
getAllArguments()method provides a map of all arguments as aname-JobArgumentobject map. - For further methods to access arguments see JS7 - Job API.
Resources
Links
- JS7 - How to add modules to GraalVM Python Jobs
- JS7 - How to read arguments in GraalVM Python Jobs
- JS7 - Job API
- JS7 - Job Classes
- JS7 - Job Resources
- JS7 - Shell Jobs
- JS7 - Order Variables
- JS7 - Adding and Updating Graal Libraries to Agents
- JS7 - GraalVM Jobs
- JS7 - GraalVM JavaScript Jobs
- JS7 - GraalVM Run-time Options
How To ... GraalVM Python