Ejemplo n.º 1
0
    def test_runopts_add(self):
        """
        tests for various add option variations
        does not assert anything, a successful test
        should not raise any unexpected errors
        """
        opts = runopts()
        opts.add("run_as", type_=str, help="run as user")
        opts.add("run_as_default",
                 type_=str,
                 help="run as user",
                 default="root")
        opts.add("run_as_required",
                 type_=str,
                 help="run as user",
                 required=True)

        with self.assertRaises(ValueError):
            opts.add("run_as",
                     type_=str,
                     help="run as user",
                     default="root",
                     required=True)

        opts.add("priority", type_=int, help="job priority", default=10)

        with self.assertRaises(TypeError):
            opts.add("priority", type_=int, help="job priority", default=0.5)

        # this print is intentional (demonstrates the intended usecase)
        print(opts)
Ejemplo n.º 2
0
 def run_opts(self) -> runopts:
     opts = runopts()
     opts.add("image_fetcher", type_=str, help="image fetcher type", default="dir")
     opts.add(
         "log_dir",
         type_=str,
         default=None,
         help="dir to write stdout/stderr log files of replicas",
     )
     return opts
Ejemplo n.º 3
0
 def run_opts(self) -> runopts:
     opts = runopts()
     opts.add("foo", type_=str, required=True, help="required option")
     return opts
Ejemplo n.º 4
0
 def get_runopts(self):
     opts = runopts()
     opts.add("run_as", type_=str, help="run as user", required=True)
     opts.add("priority", type_=int, help="job priority", default=10)
     opts.add("cluster_id", type_=str, help="cluster to submit job")
     return opts