gallop
🐎 New level of python develop. Source code from github
More dynamic in design, more configuration driven
[-;-/=_
`-; \=_ ___ _________ __ __ ____ ____
) ,"-...--./===--__ / ____/ | / / / / / __ \/ __ \
__|/ / ]` / / __/ /| | / / / / / / / / /_/ /
/;--> >...-\ <\_ / /_/ / ___ |/ /___/ /___/ /_/ / ____/
`- <<, 7/-.\, \____/_/ |_/_____/_____/\____/_/
`- /( `-
Install
pip install gallop
Configuration Management
from gallop.config import BaseConfig
config = BaseConfig(a=1)
config.a = 2
config.b = 3
config.to_json("some/path.json")
config.to_yaml("some/path.yaml")
Run python task from config
You can turn any callable execution in to configuration, eg save the following
func_name: use:logging.warning
args:
- "hello world"
to sometask.yaml and run gallop sometask
Is the same to run the python script
import logging
logging.warning("hello world")
param: configuration
We 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 key args, of its 1st element, we can run
gallop sometask --param:args.0 changed_world
Advanced usage
Some simple grammar
checkin: 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.DataFrame
Examples
Inference BERT model
If you have
transformersinstalled, you can run the following example directly to featurize a sentence
pred_task:
- func_name: use:transformers.AutoModel.from_pretrained
args:
- bert-base-uncased
checkin: model
description: |
Load pretrained model
- func_name: use:transformers.AutoTokenizer.from_pretrained
args:
- bert-base-uncased
checkin: tokenizer
description: |
Load pretrained tokenizer
- func_name: tokenizer
args:
- - "Hello, the capital of [MASK] is Paris"
kwargs:
return_tensors: pt
max_length: 128
truncation: True
padding: True
checkin: inputs
- func_name: use:logging.warning
args:
- func_name: model
kwargs:
input_ids:
checkout: inputs.input_ids
attention_mask:
checkout: inputs.attention_mask
checkin: features
This equals to the following python script
import logging
from transformers import AutoModel, AutoTokenizer
model = 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 to run_bert.yaml and you can use gallop run_bert --output features to run the task.
Run in commandline with changed value, and printout one of the checkout value
gallop run_bert --loglevel debug --output features
And run it with CHANGED VALUE
gallop run_bert 、
--param:pred_task.2.args.0.0 "The [MASK] house is where the POTUS live and work"
Related project
From the same lead author
Metadata
Release files for gallop 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gallop-0.0.6.tar.gz | 12.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gallop-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.6 kB
Release files / gallop-0.0.6.tar.gz
| Download URL | gallop-0.0.6.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00f90466f3e8c7e3da7d9e6e8ba6f7a3214e9c22116f37bb65976d9bf4c8e337
|
|
BLAKE2b-256 checksum How to use checksums |
5c2fde59cc061c0e25c8fe0f509f0456732b9ed829e8ce358f838fe624d7ad85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / gallop-0.0.6-py3-none-any.whl
| Download URL | gallop-0.0.6-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e97984c68fda04bb3717241bc8b6e8978c13cfa791c381fbe51bb86e0a0cd0e4
|
|
BLAKE2b-256 checksum How to use checksums |
f76d13a932d8864b6c2a1533889b9d3967a2adc5f79c9e7fda1960a3caaba0ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for gallop 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.