Esempio n. 1
0
    def get(self, offliner: str, *args, **kwargs):

        if offliner not in Offliner.all():
            raise NotFound()

        schema = ScheduleConfigSchema.get_offliner_schema(offliner)()

        return jsonify(schema.to_desc())
Esempio n. 2
0
    def get(self, *args, **kwargs):
        """return a list of tags"""

        offliners = Offliner.all()

        return jsonify(
            {
                "meta": {"skip": 0, "limit": 100, "count": len(offliners)},
                "items": offliners,
            }
        )
Esempio n. 3
0
def expanded_config(config):
    # update image name with registry if required
    config["image"]["name"] = Offliner.get_image_name(config["task_name"])

    # mount-point is offliner-specific
    config["mount_point"] = str(mount_point_for(config["task_name"]))
    # computed command flags
    config["command"] = command_for(
        config["task_name"], config["flags"], config["mount_point"]
    )
    # workers uses string version
    config["str_command"] = build_str_command(config["command"])
    # offliners can specify additional docker options (capabilities)
    docker_options = docker_config_for(config["task_name"])

    def get_shm(offliner_shm=None, config_shm=None):
        # use largest of /dev/shm specified (in config vs in offliner rule)
        if offliner_shm and config_shm:
            dev_shm = max([offliner_shm, config_shm])
        else:
            dev_shm = config_shm or offliner_shm

        # use at most memory for /dev/shm if specified and above memory
        if dev_shm and dev_shm > config["resources"]["memory"]:
            dev_shm = config["resources"]["memory"]
        return dev_shm

    dev_shm = get_shm(
        offliner_shm=docker_options.pop("shm", None),
        config_shm=config["resources"].get("shm"),
    )
    if dev_shm:
        config["resources"]["shm"] = dev_shm

    # offliners can update resources
    config["resources"].update(docker_options)

    return config
Esempio n. 4
0
)

# validators
validate_priority = validate.Range(min=0, max=10)
validate_schedule_name = validate.Length(min=2)
validate_not_empty = validate.Length(min=1)
validate_role = validate.OneOf(ROLES.keys())
validate_cpu = validate.Range(min=0)
validate_memory = validate.Range(min=0)
validate_disk = validate.Range(min=0)
validate_lang_code = validate.Length(min=2, max=3)
validate_output = validate.Equal("/output")
validate_category = validate.OneOf(ScheduleCategory.all())
validate_warehouse_path = validate.OneOf(
    ScheduleCategory.all_warehouse_paths())
validate_offliner = validate.OneOf(Offliner.all())
validate_status = validate.OneOf(TaskStatus.all())
validate_event = validate.OneOf(TaskStatus.all_events())
validate_worker_name = validate.Length(min=3)
validate_periodicity = validate.OneOf(SchedulePeriodicity.all())
validate_platform = validate.OneOf(Platform.all())
validate_platform_value = validate.Range(min=0)


def validate_multiple_of_100(value):
    return value % 100 == 0


# reusable fields
skip_field = fields.Integer(required=False,
                            missing=0,