Package: gallop
gallop🐎 New level of python develop. Source code fromgithubMore dynamic in design, more configuration driven[-;-/=_
    `-; \=_       ___        _________    __    __    ____  ____ 
      ) ,"-...--./===--__   / ____/   |  / /   / /   / __ \/ __ \ 
    __|/      /  ]`        / / __/ /| | / /   / /   / / / / /_/ /
   /;--> >...-\ <\_       / /_/ / ___ |/ /___/ /___/ /_/ / ____/ 
   `- <<,      7/-.\,     \____/_/  |_/_____/_____/\____/_/      
       `-     /(   `-InstallpipinstallgallopConfiguration Managementfromgallop.configimportBaseConfigconfig=BaseConfig(a=1)config.a=2config.b=3config.to_json("some/path.json")config.to_yaml("some/path.yaml")Run python task from configYou can turn any callable execution in to configuration, eg save the followingfunc_name:use:logging.warningargs:-"helloworld"tosometask.yamland rungallop sometaskIs the same to run the python scriptimportlogginglogging.warning("hello world")param:configurationWe can change the value on the run, while pointing to the position in the config, using a chain of keys (keys to dict or list).eg. to change the keyargs, of its 1st element, we can rungallopsometask--param:args.0changed_worldAdvanced usageSome simple grammarcheckin: somekey, save the result to a centralized dictionary with keysomekeycheckout: somekey, use the result from the centralized dictionary with keysomekeycheckout: env:DATA_HOME, use the result from the environment variableDATA_HOMEuse:some.module, use or import the modulesome.moduleas the callable, egfunc_name: use:os.path.join, use the functionos.path.joinfunc_name: use:pandas.DataFrame, use the classpandas.DataFrameExamplesInference BERT modelIf you havetransformersinstalled, you can run the following example directly to featurize a sentencepred_task:-func_name:use:transformers.AutoModel.from_pretrainedargs:-bert-base-uncasedcheckin:modeldescription:|Load pretrained model-func_name:use:transformers.AutoTokenizer.from_pretrainedargs:-bert-base-uncasedcheckin:tokenizerdescription:|Load pretrained tokenizer-func_name:tokenizerargs:--"Hello,thecapitalof[MASK]isParis"kwargs:return_tensors:ptmax_length:128truncation:Truepadding:Truecheckin:inputs-func_name:use:logging.warningargs:-func_name:modelkwargs:input_ids:checkout:inputs.input_idsattention_mask:checkout:inputs.attention_maskcheckin:featuresThis equals to the followingpythonscriptimportloggingfromtransformersimportAutoModel,AutoTokenizermodel=AutoModel.from_pretrained("bert-base-uncased")tokenizer=AutoTokenizer.from_pretrained("bert-base-uncased")inputs=tokenizer("Hello, the capital of [MASK] is Paris",return_tensors="pt",max_length=128,truncation=True,padding=True,)logging.warning(model(input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,))Save the yaml torun_bert.yamland you can usegallop run_bert --output featuresto run the task.Run in commandline with changed value, and printout one of the checkout valuegalloprun_bert--logleveldebug--outputfeaturesAnd run it withCHANGED VALUEgallop run_bert 、
     --param:pred_task.2.args.0.0 "The [MASK] house is where the POTUS live and work"Related projectFrom the same lead authorPythoncategorymanagement accelerated with RustData science basic toolsetforgebox