JobDescription(3pm)

πŸ¦‹ JobDescription(3pm) β€” the GRAM job description glow-up ✨

okay bestie, pull up a chair, we're talking about JobDescription(3pm) from the Perl user-contributed docs, and honestly? it's giving structured. πŸ’…

✨ NAME ✨

Globus::GRAM::JobDescription β€” a GRAM Job Description, no cap.

Globus::GRAM::DefaultHandlingJobDescription β€” a GRAM Job Description, but with relative path handling. she does a little extra. πŸŽ€


🌸 SYNOPSIS 🌸

use Globus::GRAM::JobDescription;

$hash = { executable => [ '/bin/echo' ], arguments => [ 'hello' ] };
$description = new Globus::GRAM::JobDescription($filename);
$description = new Globus::GRAM::JobDescription($hash);
$executable = $description->executable();
$description->add($new_attribute, $new_value);
$description->save();
$description->save($filename);
$description->print_recursive($file_handle);

πŸ’– DESCRIPTION πŸ’–

so like, this object is basically a little tote bag πŸ‘œ holding all the parameters of a job request, wrapped up in a nice simple object. you can poke at it to find out the value of any RSL parameter, you can update it with new parameters, and you can save it to the filesystem so you can come back to it later. she's versatile, she's lowkey iconic. ✨

🫢 Methods 🫢

  • new Globus::GRAM::JobDescription($filename)

you build a JobDescription from a file, and that file is just a Perl hash of parameter => array mappings. here's the tea tho β€” every single value in the Job Description gets stored internally as an array, even if it's just one lonely literal, because that's how an RSL tree gets parsed in C. consistency queen. πŸ‘‘

an example of such a file is

$description =
{
    executable  => [ '/bin/echo' ],
    arguments   => [ 'hello', 'world' ],
    environment => [
                       [
                           'GLOBUS_GRAM_JOB_CONTACT',
                           'https://globus.org:1234/2345/4332'
                       ]
                   ]
};

which corresponds to the rsl fragment

&(executable  = /bin/echo)
 (arguments   = hello world)
 (environment =
     (GLOBUS_GRAM_JOB_CONTACT 'https://globus.org:1234/2345/4332')
 )
and heads up: when the library_path RSL attribute is specified, this object modifies the environment RSL attribute value so it appends its value to any system specific variables. 🧚
  • $description->add('name', $value);

adds a parameter to a job description. it gets normalized internally so all the access methods below just work with the new parameter. like,

$description->add('new_attribute', $new_value)

will create a new attribute in the JobDescription, which you can then access by calling the $description-new_attribute>() method. slay. πŸ’…

  • $value $description->get('name');

grabs a parameter from a job description. for example,

$description->get('attribute')

will return the appropriate attribute in the JobDescription by name. she knows where everything is. πŸ“

  • $description->save([$filename])

saves the JobDescription β€” including any added parameters β€” to the file named by $filename if it's present, or else it replaces the file that was used when constructing the object. πŸŽ€

  • $description->print_recursive($file_handle)

writes the value of the job description object to the file handle you passed in the argument list. very demure, very mindful. 🌸

  • $description->parameter()

okay so any parameter defined in the JobDescription can be accessed by calling the method named by the parameter. the method names get automatically created when the JobDescription is created, and they can be invoked with arbitrary SillyCaps or underscores. that means the parameter gram_myjob can be accessed by the GramMyJob, grammyjob, or gram_my_job method names (and others). she's flexible like that. πŸ¦‹

if the attribute is not in this object, then undef gets returned.

in a list context, this returns the list of values associated with an attribute.

in a scalar context, if the attribute's value consists of a single literal, then that literal is returned β€” otherwise undef is returned.

for example, from a JobDescription called $d constructed from a description file containing

{
    executable => [ '/bin/echo' ],
    arguments  => [ 'hello', 'world' ]
}

the following will hold:

$executable = $d->executable()    # '/bin/echo'
$arguments = $d->arguments()      # undef
@executable = $d->executable()    # ('/bin/echo')
@arguments = $d->arguments()      # ('hello', 'world')
$not_present = $d->not_present()  # undef
@not_present = $d->not_present()  # ()

to test for existence of a value:

@not_present = $d->not_present()
print "Not defined\n" if(!defined($not_present[0]));

🌈 and that's the whole vibe 🌈

this page came from perl v5.16.3, dated 2020-12-12, bestie β€” so yeah, she's been around and she still hits. go forth and describe your jobs, you've got this. πŸ’œπŸ«Άβœ¨