Ejemplo n.º 1
0
 def _makeArgumentParser(cls):
     """Create an argument parser
     """
     return pipeBase.InputOnlyArgumentParser(
         name=cls._DefaultName,
         datasetType=pipeBase.DatasetArgument(
             help="dataset type for task metadata"))
Ejemplo n.º 2
0
    def _makeArgumentParser(cls):
        """Create an argument parser"""

        parser = pipeBase.InputOnlyArgumentParser(name=cls._DefaultName)
        parser.add_id_argument("--id", "calexp", help="Data ID, e.g. --id visit=6789 (optional)")

        return parser
Ejemplo n.º 3
0
    def testDatasetArgumentPositional(self):
        """Test DatasetArgument with a positional argument"""
        name = "foo"
        defaultDsTypeHelp = "dataset type to process from input data repository"
        ap = pipeBase.InputOnlyArgumentParser(name="argumentParser")
        dsType = pipeBase.DatasetArgument(name=name)
        self.assertEqual(dsType.help, defaultDsTypeHelp)

        ap.add_id_argument("--id", dsType, "help text")
        namespace = ap.parse_args(
            config=self.config,
            args=[DataPath,
                  "calexp",
                  "--id", "visit=2",
                  ],
        )
        self.assertEqual(namespace.id.datasetType, "calexp")
        self.assertEqual(len(namespace.id.idList), 1)

        # make sure dataset type argument is required
        with self.assertRaises(SystemExit):
            ap.parse_args(
                config=self.config,
                args=[DataPath,
                      "--id", "visit=2",
                      ],
            )
    def _makeArgumentParser(cls):
        """Create an argument parser.

        This returns a standard parser with an extra "files" argument.
        """
        parser = pipeBase.InputOnlyArgumentParser(name=cls._DefaultName)
        parser.add_argument("files", nargs="+", help="Names of files to index")
        return parser
Ejemplo n.º 5
0
    def _makeArgumentParser(cls):
        """Create an argument parser

        This overrides the original because we need the file arguments
        """
        parser = pipeBase.InputOnlyArgumentParser(name=cls._DefaultName)
        parser.add_argument("files", nargs="+", help="Names of files to index")
        return parser
Ejemplo n.º 6
0
 def setUp(self):
     self.ap = pipeBase.InputOnlyArgumentParser(name="argumentParser")
     self.ap.add_id_argument("--id", "raw", "help text")
     self.ap.add_id_argument("--otherId", "raw", "more help")
     self.config = SampleConfig()
     os.environ.pop("PIPE_INPUT_ROOT", None)
     os.environ.pop("PIPE_CALIB_ROOT", None)
     os.environ.pop("PIPE_OUTPUT_ROOT", None)
Ejemplo n.º 7
0
    def _makeArgumentParser(cls):
        """Create an argument parser

        We specify a dynamic id argument through the use of DatasetArgument.
        """
        parser = pipeBase.InputOnlyArgumentParser(name=cls._DefaultName)
        parser.add_id_argument("--id", pipeBase.DatasetArgument(help="dataset type for task metadata"),
                               help="data ID, e.g. --id visit=12345 ccd=1,2")
        return parser
Ejemplo n.º 8
0
    def _makeArgumentParser(cls):
        """Create an argument parser

        Use datasetType="deepCoadd" to get the right keys (even chi-squared coadds
        need filter information for this particular task).
        """
        parser = pipeBase.InputOnlyArgumentParser(name=cls._DefaultName)
        parser.add_id_argument("--id", "deepCoadd", help="data ID, e.g. --id tract=12345 patch=1,2",
                               ContainerClass=ReportImagesInPatchDataIdContainer)
        return parser
Ejemplo n.º 9
0
    def _makeArgumentParser(cls):
        """Create an argument parser

        Use datasetType="deepCoadd" to get the right keys (even chi-squared coadds
        need filter information for this particular task).
        """
        parser = pipeBase.InputOnlyArgumentParser(name=cls._DefaultName)
        parser.add_id_argument(
            name="--id",
            datasetType="deepCoadd",
            help="data ID, e.g. --id filter=i",
            ContainerClass=SkyMapPlusFilterIdContainer,
        )
        return parser
    def testDatasetArgumentBasics(self):
        """Test DatasetArgument basics"""
        dsTypeHelp = "help text for dataset argument"
        for name in (None, "--foo"):
            for default in (None, "raw"):
                argName = name if name is not None else "--id_dstype"
                ap = pipeBase.InputOnlyArgumentParser(name="argumentParser")
                dsType = pipeBase.DatasetArgument(name=name,
                                                  help=dsTypeHelp,
                                                  default=default)
                self.assertEqual(dsType.help, dsTypeHelp)

                ap.add_id_argument("--id", dsType, "help text")
                namespace = ap.parse_args(
                    config=self.config,
                    args=[
                        DataPath,
                        argName,
                        "calexp",
                        "--id",
                        "visit=2",
                    ],
                )
                self.assertEqual(namespace.id.datasetType, "calexp")
                self.assertEqual(len(namespace.id.idList), 1)

                del namespace

                if default is None:
                    # make sure dataset type argument is required
                    with self.assertRaises(SystemExit):
                        ap.parse_args(
                            config=self.config,
                            args=[
                                DataPath,
                                "--id",
                                "visit=2",
                            ],
                        )
                else:
                    namespace = ap.parse_args(
                        config=self.config,
                        args=[
                            DataPath,
                            "--id",
                            "visit=2",
                        ],
                    )
                    self.assertEqual(namespace.id.datasetType, default)
                    self.assertEqual(len(namespace.id.idList), 1)
Ejemplo n.º 11
0
    def testConfigDatasetTypeNoFieldDefault(self):
        """Test ConfigDatasetType with a config field that has no default value"""
        name = "dsTypeNoDefault"
        ap = pipeBase.InputOnlyArgumentParser(name="argumentParser")
        dsType = pipeBase.ConfigDatasetType(name=name)

        ap.add_id_argument("--id", dsType, "help text")
        # neither the argument nor the config field has a default,
        # so the user must specify the argument (or specify doMakeDataRefList=False
        # and post-process the ID list)
        with self.assertRaises(RuntimeError):
            ap.parse_args(
                config=self.config,
                args=[DataPath,
                      "--id", "visit=2",
                      ],
            )
Ejemplo n.º 12
0
    def testConfigDatasetTypeFieldDefault(self):
        """Test ConfigDatasetType with a config field that has a default value"""
        # default value for config field "dsType" is "calexp";
        # use a different value as the default for the ConfigDatasetType
        # so the test can tell the difference
        name = "dsType"
        ap = pipeBase.InputOnlyArgumentParser(name="argumentParser")
        dsType = pipeBase.ConfigDatasetType(name=name)

        ap.add_id_argument("--id", dsType, "help text")
        namespace = ap.parse_args(
            config=self.config,
            args=[DataPath,
                  "--id", "visit=2",
                  ],
        )
        self.assertEqual(namespace.id.datasetType, "calexp")  # default of config field dsType
        self.assertEqual(len(namespace.id.idList), 1)
Ejemplo n.º 13
0
 def makeArgumentParser(cls):
     parser = pipeBase.InputOnlyArgumentParser(name=cls._DefaultName)
     parser.add_id_argument("--id", "raw", help="data IDs, e.g. --id visit=12345 ccd=1,2^0,3")
     return parser