Example #1
0
            Optional("recalculate_value"): Bool(),
        }),
        Optional("keep_in_memory"):
        Bool(),
        Optional("internals_folder_path"):
        Bool(),
        Optional("modalities_to_use"):
        Seq(Str()),
        Optional("modalities_weights"):
        Any(),
        "main_modality":
        Str(),
    }),
    'topics':
    Map({
        "background_topics": Seq(Str()) | Int() | EmptyList(),
        "specific_topics": Seq(Str()) | Int() | EmptyList(),
    })
})
KEY_DICTIONARY_FILTER_PARAMETERS = 'dictionary_filter_parameters'


def build_schema_from_signature(class_of_object, use_optional=True):
    """
    Parameters
    ----------
    class_of_object : class

    Returns
    -------
    dict
Example #2
0
    "install_msg": Str(),
    "author": Seq(Str()),
    **COMMON_KEYS,
}

#: `cogs` metadata keys.
COG_KEYS = {
    "name": Str(),  # Downloader doesn't use this but I can set friendlier name
    "short": Str(),
    "description": Str(),
    "end_user_data_statement": Str(),
    Optional("class_docstring"): Str(),
    Optional("install_msg"): Str(),
    Optional("author"): Seq(Str()),
    Optional("required_cogs", {}): EmptyDict() | MapPattern(Str(), Url()),
    Optional("requirements", []): EmptyList() | Seq(Str()),
    Optional("tags", []): EmptyList() | Seq(Str()),
    **COMMON_KEYS,
}

#: Root schema of the info.yaml file.
SCHEMA = Map({
    "repo": Map(REPO_KEYS),
    "shared_fields": Map(SHARED_FIELDS_KEYS),
    "cogs": MapPattern(Str(), Map(COG_KEYS)),
})

#: Keys that should be skipped when outputting to info.json.
#: These keys are for infogen's usage.
KEYS_TO_SKIP_IN_COG_INFO = {"class_docstring"}
Example #3
0
    def __init__(self) -> None:
        from strictyaml import Map, MapPattern, Optional, Str, Seq, Int, Bool, EmptyList, OrValidator

        d_named_object = {
            'name': Str(),
            'description': Str(),
        }

        d_feture_check = {
            Optional('since', default=''): Str(),
            Optional('deprecated', default=''): Str(),
        }

        self.s_posarg = Map({
            **d_feture_check,
            'description': Str(),
            'type': Str(),
            Optional('default', default=''): Str(),
        })

        self.s_varargs = Map({
            **d_named_object,
            **d_feture_check,
            'type': Str(),
            Optional('min_varargs', default=-1): Int(),
            Optional('max_varargs', default=-1): Int(),
        })

        self.s_kwarg = Map({
            **d_feture_check,
            'type': Str(),
            'description': Str(),
            Optional('required', default=False): Bool(),
            Optional('default', default=''): Str(),
        })

        self.s_function = Map({
            **d_named_object,
            **d_feture_check,
            'returns':
            Str(),
            Optional('notes', default=[]):
            OrValidator(Seq(Str()), EmptyList()),
            Optional('warnings', default=[]):
            OrValidator(Seq(Str()), EmptyList()),
            Optional('example', default=''):
            Str(),
            Optional('posargs'):
            MapPattern(Str(), self.s_posarg),
            Optional('optargs'):
            MapPattern(Str(), self.s_posarg),
            Optional('varargs'):
            self.s_varargs,
            Optional('posargs_inherit', default=''):
            Str(),
            Optional('optargs_inherit', default=''):
            Str(),
            Optional('varargs_inherit', default=''):
            Str(),
            Optional('kwargs'):
            MapPattern(Str(), self.s_kwarg),
            Optional('kwargs_inherit', default=[]):
            OrValidator(OrValidator(Seq(Str()), EmptyList()), Str()),
        })

        self.s_object = Map({
            **d_named_object,
            **d_feture_check, 'long_name':
            Str(),
            Optional('extends', default=''):
            Str(),
            Optional('notes', default=[]):
            OrValidator(Seq(Str()), EmptyList()),
            Optional('warnings', default=[]):
            OrValidator(Seq(Str()), EmptyList()),
            Optional('example', default=''):
            Str(),
            Optional('methods'):
            Seq(self.s_function),
            Optional('is_container', default=False):
            Bool()
        })
Example #4
0
     'start_delay':
     Int()
 }),
 'satellites':
 Seq(
     Map({
         'hostname': Str(),
         Optional('ip', default=''): Str(),
         'type': Str(),
         'ami': Str(),
         'snap': Str(),
         'user': Str(),
         'cmd': Str(),
         'tle1': Str(),
         'tle2': Str(),
         Optional('links'): Seq(Str()) | EmptyList(),
         Optional('midar'): Map({'state': Str()})
     })),
 'stations':
 Seq(
     Map({
         'hostname': Str(),
         Optional('ip', default=''): Str(),
         'type': Str(),
         'ami': Str(),
         'snap': Str(),
         'user': Str(),
         'cmd': Str(),
         'lat': Float(),
         'lon': Float(),
         'alt': Float(),
Example #5
0
def generate_schema(
    stage_actions: OptionalType[List[str]] = None,
    default_compute_type: OptionalType[str] = None,
    default_image: OptionalType[str] = None,
    log_group_config: Dict = None,
) -> Map:
    """Generate a schema"""
    input_artifact_validator = Str()
    if stage_actions:
        input_artifact_validator = Enum(stage_actions)

    name_validation_key = Optional("name")
    if (log_group_config and log_group_config["enabled"]
            and not log_group_config["create"]):
        # name becomes mandatory if we're not creating it and it's enabled
        name_validation_key = "name"

    log_group_validator = {
        Optional(
            "enabled",
            default=CODEBUILD_DEFAULTS["log_group"]["enabled"],
        ):
        Bool(),
        name_validation_key:
        Str(),
        Optional(
            "create",
            default=CODEBUILD_DEFAULTS["log_group"]["create"],
        ):
        Bool(),
        Optional("retention"):
        Int(),
    }

    return Map({
        "config":
        Map({
            "s3_bucket":
            Str(),
            "kms_key_arn":
            Str(),
            Optional(
                "codepipeline",
                default=CODEPIPELINE_DEFAULTS,
            ):
            Map({
                Optional(
                    "restart_execution_on_update",
                    default=CODEPIPELINE_DEFAULTS["restart_execution_on_update"],
                ):
                Bool(),
            }),
            Optional("codebuild", default=CODEBUILD_DEFAULTS):
            Map({
                Optional(
                    "compute_type",
                    default=CODEBUILD_DEFAULTS["compute_type"],
                ):
                Str(),
                Optional(
                    "image",
                    default=CODEBUILD_DEFAULTS["image"],
                ):
                Str(),
                Optional(
                    "log_group",
                    default=CODEBUILD_DEFAULTS["log_group"],
                ):
                Map(log_group_validator),
            }),
            Optional("iam", default=[]):
            EmptyList()
            | Seq(
                Map({
                    Optional("Effect", default="Allow"):
                    Enum(["Allow", "Deny"]),
                    "Action":
                    Seq(Str()),
                    "Resource":
                    Seq(Str()),
                })),
        }),
        "sources":
        Seq(
            Map({
                "name": UniqueStr(),
                "from": Enum(["CodeCommit", "CodeStarConnection"]),
                "repository": Str(),
                "branch": Str(),
                Optional("poll_for_source_changes", default=False): Bool(),
                Optional("event_for_source_changes", default=True): Bool(),
                Optional("connection_arn"): Str(),
            })),
        "stages":
        Seq(
            Map({
                "name":
                UniqueStr(),
                Optional("enabled", default=True):
                Bool(),
                "actions":
                Seq(
                    Map({
                        "name":
                        UniqueStr(),
                        Optional("category", default="Build"):
                        Enum(["Build", "Test", "Deploy"]),
                        Optional("provider", default="CodeBuild"):
                        Enum(["CodeBuild"]),
                        Optional("buildspec"):
                        Str(),
                        Optional("commands"):
                        Seq(Str()),
                        Optional("artifacts"):
                        Seq(Str()),
                        Optional(
                            "compute_type",
                            default=default_compute_type,
                        ):
                        Str(),
                        Optional("image", default=default_image):
                        Str(),
                        Optional("environment", default={}):
                        EmptyDict()
                        | MapPattern(Str(), Str()),
                        Optional("input_artifacts", default=[]):
                        EmptyList()
                        | Seq(input_artifact_validator),
                    })),
            })),
    })
Example #6
0
    Optional('min_varargs', default=-1): Int(),
    Optional('max_varargs', default=-1): Int(),
})

s_kwarg = Map({
    **d_feture_check,
    'type': Str(),
    'description': Str(),
    Optional('required', default=False): Bool(),
    Optional('default', default=''): Str(),
})

s_function = Map({
    **d_named_object, **d_feture_check,
    'returns': Str(),
    Optional('notes', default=[]): OrValidator(Seq(Str()), EmptyList()),
    Optional('warnings', default=[]): OrValidator(Seq(Str()), EmptyList()),
    Optional('example', default=''): Str(),
    Optional('posargs'): MapPattern(Str(), s_posarg),
    Optional('optargs'): MapPattern(Str(), s_posarg),
    Optional('varargs'): s_varargs,
    Optional('posargs_inherit', default=''): Str(),
    Optional('optargs_inherit', default=''): Str(),
    Optional('varargs_inherit', default=''): Str(),
    Optional('kwargs'): MapPattern(Str(), s_kwarg),
    Optional('kwargs_inherit', default=[]): OrValidator(OrValidator(Seq(Str()), EmptyList()), Str()),
})

s_object = Map({
    **d_named_object, **d_feture_check,
    'long_name': Str(),
        },
        USE_FOR_ROUTES_AT_STOP: True,
    },
    "realtime": {
        SOURCE: models.ServiceMapGroup.ServiceMapSource.REALTIME,
        USE_FOR_STOPS_IN_ROUTE: True,
        USE_FOR_ROUTES_AT_STOP: True,
    },
}

_schema = Map(
    {
        NAME: Str(),
        Optional(PREFERRED_ID): Str(),
        Optional(TIMEZONE): Timezone(),
        Optional(REQUIRED_SETTINGS, []): Seq(Str()) | EmptyList(),
        Optional(REQUIREMENTS, {PACKAGES: [], SETTINGS: []}): Map(  # Ignored
            {
                Optional(PACKAGES, []): Seq(Str()) | EmptyList(),
                Optional(SETTINGS, []): Seq(Str()) | EmptyList(),
            }
        ),
        FEEDS: MapPattern(
            Str(),
            Map(
                {
                    HTTP: Map(
                        {
                            URL: Str(),
                            Optional(HEADERS, {}): MapPattern(Str(), Str())
                            | EmptyDict(),