Ejemplo n.º 1
0
    def _config_summary(self, lines, prefix=""):
        options = {option.key: option for option in self.config_spec}
        options["name"] = ConfigOption("name", self.module_name)
        options["seed"] = ConfigOption("seed", _DEFAULT_RANDOM_SEED,
                                       "random seed")

        # show name, followed by module config, followed by dependencies
        order = sorted(self.config.keys(),
                       key=lambda x:
                       (x != "name", x in self._dependency_objects, x))
        for key in order:
            if key in self._dependency_objects:
                lines.append(f"{prefix}{key}:{Style.RESET_ALL}")
                childprefix = prefix + "  "
                if key in self._provided_dependency:
                    lines.append(
                        f"{childprefix}{Style.DIM}[provided by pipeline]{Style.RESET_ALL}"
                    )
                else:
                    self._dependency_objects[key]._config_summary(
                        lines, prefix=childprefix)
            else:
                if options[key].description:
                    lines.append(
                        f"{prefix}{Style.DIM}# {options[key].description}{Style.RESET_ALL}"
                    )

                color = ""
                if self.config[key] != options[key].default_value:
                    color = Fore.GREEN
                lines.append(
                    f"{color}{prefix}{key} = {self._config_as_strings[key]}{Style.RESET_ALL}"
                )
Ejemplo n.º 2
0
 class AFoo(ModuleTypeA):
     module_name = "AFoo"
     config_spec = [
         ConfigOption(key="foo1",
                      default_value="val1",
                      description="test option"),
         ConfigOption(key="changethis",
                      default_value=0,
                      description="something to override"),
     ]
     dependencies = [
         Dependency(key="myfoobar", module="Atype", name="AFooBar")
     ]
Ejemplo n.º 3
0
 class ModuleA(SimpleModuleType):
     module_name = "A"
     config_spec = [
         ConfigOption(key="key1",
                      default_value="val1",
                      description="test option")
     ]
Ejemplo n.º 4
0
 class AFooBar(ModuleTypeA):
     module_name = "AFooBar"
     config_spec = [
         ConfigOption(key="foobar1",
                      default_value="val1",
                      description="test option")
     ]
Ejemplo n.º 5
0
 class AParent(ModuleTypeA):
     module_name = "AParent"
     config_spec = [
         ConfigOption(key="key1",
                      default_value="val1",
                      description="test option")
     ]
     dependencies = [
         Dependency(key="myfoo",
                    module="Atype",
                    name="AFoo",
                    default_config_overrides={"changethis": 42}),
         Dependency(key="bar", module="Atype", name="ABar"),
     ]
Ejemplo n.º 6
0
 class ModuleFoo(ModuleBase):
     module_type = "Atype"
     module_name = "foo"
     config_spec = [
         ConfigOption(key="str1", default_value="foo"),
         ConfigOption(key="str2", default_value=9, value_type=str),
         ConfigOption(key="int1", default_value=2),
         ConfigOption(key="int2", default_value="3", value_type=int),
         ConfigOption(key="float1", default_value=2.2),
         ConfigOption(key="float2", default_value="3.3", value_type=float),
         ConfigOption(key="bool1", default_value=False),
         ConfigOption(key="bool2", default_value="false", value_type=bool),
         ConfigOption(key="bool3", default_value="true", value_type=bool),
         ConfigOption(key="strlist1", default_value=3, value_type="strlist"),
         ConfigOption(key="strlist2", default_value=[4, 5], value_type="strlist"),
         ConfigOption(key="strlist3", default_value="4,5", value_type="strlist"),
         ConfigOption(key="intlist1", default_value=3, value_type="intlist"),
         ConfigOption(key="intlist2", default_value="3", value_type="intlist"),
         ConfigOption(key="intlist3", default_value=(4, 5), value_type="intlist"),
         ConfigOption(key="intlist4", default_value="4,5", value_type="intlist"),
         ConfigOption(key="floatlist1", default_value=3, value_type="floatlist"),
         ConfigOption(key="none-or-str", default_value=None),
     ]