Esempio n. 1
0
 def test_22_from_batch_command(self):
     """Test that `from_batch_command` produces a valid jobspec"""
     jobid = job.submit(
         self.fh, JobspecV1.from_batch_command("#!/bin/sh\nsleep 0", "nested sleep")
     )
     self.assertGreater(jobid, 0)
     # test that a shebang is required
     with self.assertRaises(ValueError):
         job.submit(
             self.fh,
             JobspecV1.from_batch_command("sleep 0", "nested sleep with no shebang"),
         )
Esempio n. 2
0
    def init_jobspec(self, args):
        # If no script (reading from stdin), then use "flux" as arg[0]
        if not args.nslots:
            raise ValueError("Number of slots to allocate must be specified")

        jobspec = JobspecV1.from_batch_command(
            script=self.read_script(args),
            jobname=args.SCRIPT[0] if args.SCRIPT else "batchscript",
            args=args.SCRIPT[1:],
            num_slots=args.nslots,
            cores_per_slot=args.cores_per_slot,
            gpus_per_slot=args.gpus_per_slot,
            num_nodes=args.nodes,
            broker_opts=list_split(args.broker_opts),
        )

        # Default output is flux-{{jobid}}.out
        # overridden by either --output=none or --output=kvs
        if not args.output:
            jobspec.stdout = "flux-{{id}}.out"
        return jobspec