Ejemplo n.º 1
0
 def __init__(self, defaults):
     defaults = utils.read_json(defaults)
     self.defaults = {k: v for k, v in defaults.items() if k != "schema"}
     self.schema = ParamToolsSchema().load(defaults.get("schema", {}))
     (self.BaseParamSchema, self.label_validators) = get_param_schema(
         self.schema
     )
Ejemplo n.º 2
0
 def __init__(self, defaults, field_map={}):
     defaults = utils.read_json(defaults)
     schema = defaults.get("schema", {})
     self.defaults = {k: v for k, v in defaults.items() if k != "schema"}
     (self.BaseParamSchema, self.label_validators) = get_param_schema(
         schema, field_map=field_map
     )
Ejemplo n.º 3
0
 def read_params(self, params_or_path):
     if isinstance(params_or_path, str) and os.path.exists(params_or_path):
         params = utils.read_json(params_or_path)
     elif isinstance(params_or_path, str):
         params = json.loads(params_or_path)
     elif isinstance(params_or_path, dict):
         params = params_or_path
     else:
         raise ValueError("params_or_path is not dict or file path")
     return params
Ejemplo n.º 4
0
    def read_params(
        self,
        params_or_path: FileDictStringLike,
        storage_options: Optional[Dict[str, Any]] = None,
    ):
        """
        Read JSON data of the form:

        - Python `dict`.
        - JSON string.
        - Local file path.
        - Any URL readable by fsspec. For example:
            - s3: `s3://paramtools-test/defaults.json`
            - gcs: `gs://paramtools-dev/defaults.json`
            - http: `https://somedomain.com/defaults.json`
            - github: `github://PSLmodels:ParamTools@master/paramtools/tests/defaults.json`

        **Returns**
        - `params`: Python Dict created from JSON file.
        """

        return utils.read_json(params_or_path, storage_options)
Ejemplo n.º 5
0
 def __init__(self, schema, defaults, field_map={}):
     schema = utils.read_json(schema)
     (self.BaseParamSchema, self.dim_validators) = get_param_schema(
         schema, field_map=field_map
     )
     self.defaults = utils.read_json(defaults)