{"id":24912833,"url":"https://github.com/raynardj/gallop","last_synced_at":"2025-09-13T14:41:40.483Z","repository":{"id":58199604,"uuid":"530542504","full_name":"raynardj/gallop","owner":"raynardj","description":"🐎 New level of python develop","archived":false,"fork":false,"pushed_at":"2022-09-09T13:34:50.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-30T00:19:24.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raynardj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-30T07:20:15.000Z","updated_at":"2022-10-05T03:59:18.000Z","dependencies_parsed_at":"2022-09-02T04:02:57.415Z","dependency_job_id":null,"html_url":"https://github.com/raynardj/gallop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/raynardj/gallop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fgallop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fgallop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fgallop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fgallop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raynardj","download_url":"https://codeload.github.com/raynardj/gallop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fgallop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260787556,"owners_count":23063147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-02T05:28:41.907Z","updated_at":"2025-06-19T16:35:48.197Z","avatar_url":"https://github.com/raynardj.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gallop\n🐎 New level of python develop. Source code from [github](https://github.com/raynardj/gallop)\n\n\u003e More dynamic in design, more configuration driven\n\n[![PyPI version](https://img.shields.io/pypi/v/gallop)](https://pypi.org/project/gallop/)\n![License](https://img.shields.io/github/license/raynardj/forgebox)\n[![Test](https://github.com/raynardj/gallop/actions/workflows/test.yml/badge.svg)](https://github.com/raynardj/gallop/actions/workflows/test.yml)\n[![pypi build](https://github.com/raynardj/gallop/actions/workflows/publish.yml/badge.svg)](https://github.com/raynardj/gallop/actions/workflows/publish.yml)\n\n```\n   [-;-/=_\n    `-; \\=_       ___        _________    __    __    ____  ____ \n      ) ,\"-...--./===--__   / ____/   |  / /   / /   / __ \\/ __ \\ \n    __|/      /  ]`        / / __/ /| | / /   / /   / / / / /_/ /\n   /;--\u003e \u003e...-\\ \u003c\\_       / /_/ / ___ |/ /___/ /___/ /_/ / ____/ \n   `- \u003c\u003c,      7/-.\\,     \\____/_/  |_/_____/_____/\\____/_/      \n       `-     /(   `-     \n```\n\n## Install\n```shell\npip install gallop\n```\n\n## Configuration Management\n```python\nfrom gallop.config import BaseConfig\n\nconfig = BaseConfig(a=1)\nconfig.a = 2\nconfig.b = 3\n\nconfig.to_json(\"some/path.json\")\nconfig.to_yaml(\"some/path.yaml\")\n```\n\n## Run python task from config\nYou can turn any callable execution in to configuration, eg save the following\n```yaml\nfunc_name: use:logging.warning\nargs:\n  - \"hello world\"\n```\n\nto `sometask.yaml` and run `gallop sometask`\n\nIs the same to run the python script\n```python\nimport logging\nlogging.warning(\"hello world\")\n```\n\n### `param:` configuration\nWe 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).\n\neg. to change the key `args`, of its 1st element, we can run\n```shell\ngallop sometask --param:args.0 changed_world\n```\n\n## Advanced usage\n### Some simple grammar\n* `checkin: somekey`, save the result to a centralized dictionary with key `somekey`\n* `checkout: somekey`, use the result from the centralized dictionary with key `somekey`\n* `checkout: env:DATA_HOME`, use the result from the environment variable `DATA_HOME`\n* `use:some.module`, use or import the module `some.module` as the callable, eg\n    * `func_name: use:os.path.join`, use the function `os.path.join`\n    * `func_name: use:pandas.DataFrame`, use the class `pandas.DataFrame`\n\n### Examples\n#### Inference BERT model\n\u003e If you have `transformers` installed, you can run the following example directly to featurize a sentence\n\n```yaml\npred_task:\n  - func_name: use:transformers.AutoModel.from_pretrained\n    args:\n      - bert-base-uncased\n    checkin: model\n    description: |\n      Load pretrained model\n  - func_name: use:transformers.AutoTokenizer.from_pretrained\n    args:\n      - bert-base-uncased\n    checkin: tokenizer\n    description: |\n      Load pretrained tokenizer\n  - func_name: tokenizer\n    args:\n      - - \"Hello, the capital of [MASK] is Paris\"\n    kwargs:\n      return_tensors: pt\n      max_length: 128\n      truncation: True\n      padding: True\n    checkin: inputs\n  - func_name: use:logging.warning\n    args:\n      - func_name: model\n        kwargs:\n          input_ids:\n            checkout: inputs.input_ids\n          attention_mask:\n            checkout: inputs.attention_mask\n        checkin: features\n```\n\nThis equals to the following `python` script\n```python\nimport logging\nfrom transformers import AutoModel, AutoTokenizer\n\nmodel = AutoModel.from_pretrained(\"bert-base-uncased\")\ntokenizer = AutoTokenizer.from_pretrained(\"bert-base-uncased\")\ninputs = tokenizer(\n    \"Hello, the capital of [MASK] is Paris\",\n    return_tensors=\"pt\",\n    max_length=128,\n    truncation=True,\n    padding=True,\n)\nlogging.warning(model(\n    input_ids=inputs.input_ids,\n    attention_mask=inputs.attention_mask,\n))\n```\n\nSave the yaml to `run_bert.yaml` and you can use `gallop run_bert --output features` to run the task.\n\nRun in commandline with changed value, and printout one of the checkout value\n```shell\ngallop run_bert --loglevel debug --output features\n```\n\nAnd run it with `CHANGED VALUE`\n```\ngallop run_bert 、\n     --param:pred_task.2.args.0.0 \"The [MASK] house is where the POTUS live and work\"   \n```\n\n\n## Related project\n\u003e From the same lead author\n* Python [category](https://github.com/raynardj/category) management accelerated with Rust\n* Data science basic toolset [forgebox](https://github.com/raynardj/forgebox)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraynardj%2Fgallop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraynardj%2Fgallop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraynardj%2Fgallop/lists"}