docstr: Decorator to specify a .json file that defines default values for the decorated callable.
  The location of the file can either be specified explicitly with `file`, or it can be
  retrieved when the decorated callable is called through an argument key/index given by `key`
  
  Parameters
  ----------
  key: String, or integer, default=None
      Used only if `file` is not also given. Determines a value for `file` based on the
      parameters passed to the decorated callable. If string, represents a key in `kwargs`
      passed to :meth:`ParametersFromFile.__call__`. In other words, this names a keyword
      argument passed to the decorated callable. If `key` is integer, it represents an index
      in `args` passed to :meth:`ParametersFromFile.__call__`, the value at which specifies a
      filepath containing the default parameters dict to use
  file: String, default=None
      If not None, `key` will be ignored, and `file` will be used as the filepath from which
      to read the dict of default parameters for the decorated callable
  verbose: Boolean, default=False
      If True, will log messages when invalid keys are found in the parameters file, and when
      keys are set to the default values in the parameters file. Else, logging is silenced
  
  Notes
  -----
  The order of precedence for determining the value of each parameter is as follows, with
  items at the top having the highest priority, and deferring only to the items below if
  their own value is not given:
  
  * 1)parameters explicitly passed to the callable decorated by `ParametersFromFile`,
  * 2)parameters in the .json file denoted by `key` or `file`,
  * 3)parameter defaults defined in the signature of the decorated callable
  
  Examples
  --------
  >>> from tempfile import TemporaryDirectory
  >>> with TemporaryDirectory(dir="") as d:
  ...     write_json(f"{d}/config.json", dict(b="I came from config.json", c="Me too!"))
  ...     @ParametersFromFile(file=f"{d}/config.json")
  ...     def f_0(a="first_a", b="first_b", c="first_c"):
  ...         print(f"{a}   ...   {b}   ...   {c}")
  ...     @ParametersFromFile(key="config_file")
  ...     def f_1(a="second_a", b="second_b", c="second_c", config_file=None):
  ...         print(f"{a}   ...   {b}   ...   {c}")
  ...     f_0(c="Hello, there")
  ...     f_0(b="General Kenobi")
  ...     f_1()
  ...     f_1(a="Generic prequel meme", config_file=f"{d}/config.json")
  ...     f_1(c="This is where the fun begins", config_file=None)
  first_a   ...   I came from config.json   ...   Hello, there
  first_a   ...   General Kenobi   ...   Me too!
  second_a   ...   second_b   ...   second_c
  Generic prequel meme   ...   I came from config.json   ...   Me too!
  second_a   ...   second_b   ...   This is where the fun begins
docstr_tok: ["Decorator","to","specify","a",".json","file","that","defines","default","values","for","the","decorated","callable",".","The","location","of","the","file","can","either","be","specified","explicitly","with","`","file","`",",","or","it","can","be","retrieved","when","the","decorated","callable","is","called","through","an","argument","key\/index","given","by","`","key","`","Parameters","--","--","--","--","--","key",":","String",",","or","integer",",","default=None","Used","only","if","`","file","`","is","not","also","given",".","Determines","a","value","for","`","file","`","based","on","the","parameters","passed","to","the","decorated","callable",".","If","string",",","represents","a","key","in","`","kwargs","`","passed","to",":","meth",":","`","ParametersFromFile.__call__","`",".","In","other","words",",","this","names","a","keyword","argument","passed","to","the","decorated","callable",".","If","`","key","`","is","integer",",","it","represents","an","index","in","`","args","`","passed","to",":","meth",":","`","ParametersFromFile.__call__","`",",","the","value","at","which","specifies","a","filepath","containing","the","default","parameters","dict","to","use","file",":","String",",","default=None","If","not","None",",","`","key","`","will","be","ignored",",","and","`","file","`","will","be","used","as","the","filepath","from","which","to","read","the","dict","of","default","parameters","for","the","decorated","callable","verbose",":","Boolean",",","default=False","If","True",",","will","log","messages","when","invalid","keys","are","found","in","the","parameters","file",",","and","when","keys","are","set","to","the","default","values","in","the","parameters","file",".","Else",",","logging","is","silenced","Notes","--","--","-","The","order","of","precedence","for","determining","the","value","of","each","parameter","is","as","follows",",","with","items","at","the","top","having","the","highest","priority",",","and","deferring","only","to","the","items","below","if","their","own","value","is","not","given",":","*","1",")","parameters","explicitly","passed","to","the","callable","decorated","by","`","ParametersFromFile","`",",","*","2",")","parameters","in","the",".json","file","denoted","by","`","key","`","or","`","file","`",",","*","3",")","parameter","defaults","defined","in","the","signature","of","the","decorated","callable","Examples","--","--","--","--",">",">",">","from","tempfile","import","TemporaryDirectory",">",">",">","with","TemporaryDirectory","(","dir=","''","''",")","as","d",":","...","write_json","(","f","''","{","d","}","\/config.json","''",",","dict","(","b=","''","I","came","from","config.json","''",",","c=","''","Me","too","!","''",")",")","...","@","ParametersFromFile","(","file=f","''","{","d","}","\/config.json","''",")","...","def","f_0","(","a=","''","first_a","''",",","b=","''","first_b","''",",","c=","''","first_c","''",")",":","...","print","(","f","''","{","a","}","...","{","b","}","...","{","c","}","''",")","...","@","ParametersFromFile","(","key=","''","config_file","''",")","...","def","f_1","(","a=","''","second_a","''",",","b=","''","second_b","''",",","c=","''","second_c","''",",","config_file=None",")",":","...","print","(","f","''","{","a","}","...","{","b","}","...","{","c","}","''",")","...","f_0","(","c=","''","Hello",",","there","''",")","...","f_0","(","b=","''","General","Kenobi","''",")","...","f_1","(",")","...","f_1","(","a=","''","Generic","prequel","meme","''",",","config_file=f","''","{","d","}","\/config.json","''",")","...","f_1","(","c=","''","This","is","where","the","fun","begins","''",",","config_file=None",")","first_a","...","I","came","from","config.json","...","Hello",",","there","first_a","...","General","Kenobi","...","Me","too","!","second_a","...","second_b","...","second_c","Generic","prequel","meme","...","I","came","from","config.json","...","Me","too","!","second_a","...","second_b","...","This","is","where","the","fun","begins"]
code: def __init__(
      self,
      key: Union[str, int] = None,
      file: str = None,
      verbose: bool = False,
  ):
      """Decorator to specify a .json file that defines default values for the decorated callable.
      The location of the file can either be specified explicitly with `file`, or it can be
      retrieved when the decorated callable is called through an argument key/index given by `key`
  
      Parameters
      ----------
      key: String, or integer, default=None
          Used only if `file` is not also given. Determines a value for `file` based on the
          parameters passed to the decorated callable. If string, represents a key in `kwargs`
          passed to :meth:`ParametersFromFile.__call__`. In other words, this names a keyword
          argument passed to the decorated callable. If `key` is integer, it represents an index
          in `args` passed to :meth:`ParametersFromFile.__call__`, the value at which specifies a
          filepath containing the default parameters dict to use
      file: String, default=None
          If not None, `key` will be ignored, and `file` will be used as the filepath from which
          to read the dict of default parameters for the decorated callable
      verbose: Boolean, default=False
          If True, will log messages when invalid keys are found in the parameters file, and when
          keys are set to the default values in the parameters file. Else, logging is silenced
  
      Notes
      -----
      The order of precedence for determining the value of each parameter is as follows, with
      items at the top having the highest priority, and deferring only to the items below if
      their own value is not given:
  
      * 1)parameters explicitly passed to the callable decorated by `ParametersFromFile`,
      * 2)parameters in the .json file denoted by `key` or `file`,
      * 3)parameter defaults defined in the signature of the decorated callable
  
      Examples
      --------
      >>> from tempfile import TemporaryDirectory
      >>> with TemporaryDirectory(dir="") as d:
      ...     write_json(f"{d}/config.json", dict(b="I came from config.json", c="Me too!"))
      ...     @ParametersFromFile(file=f"{d}/config.json")
      ...     def f_0(a="first_a", b="first_b", c="first_c"):
      ...         print(f"{a}   ...   {b}   ...   {c}")
      ...     @ParametersFromFile(key="config_file")
      ...     def f_1(a="second_a", b="second_b", c="second_c", config_file=None):
      ...         print(f"{a}   ...   {b}   ...   {c}")
      ...     f_0(c="Hello, there")
      ...     f_0(b="General Kenobi")
      ...     f_1()
      ...     f_1(a="Generic prequel meme", config_file=f"{d}/config.json")
      ...     f_1(c="This is where the fun begins", config_file=None)
      first_a   ...   I came from config.json   ...   Hello, there
      first_a   ...   General Kenobi   ...   Me too!
      second_a   ...   second_b   ...   second_c
      Generic prequel meme   ...   I came from config.json   ...   Me too!
      second_a   ...   second_b   ...   This is where the fun begins"""
      self.key = key
      self.file = file
      self.verbose = verbose
  
imports: from hyperparameter_hunter.settings import G
  from contextlib import suppress
  from inspect import signature
  import numpy
  import os
  import os.path
  import pandas
  import simplejson
  from typing import Union
  import wrapt
label_desc: Use image node_id 1 to create a new ParametersFromFile object from inherited base classes: object with example: obj = ParametersFromFile(key, file, verbose)