{"id":20751023,"url":"https://github.com/vaaaaanquish/gokart-examples","last_synced_at":"2025-07-13T20:03:48.818Z","repository":{"id":113485706,"uuid":"240204444","full_name":"vaaaaanquish/gokart-examples","owner":"vaaaaanquish","description":"gokart examples for m3 techbook 2","archived":false,"fork":false,"pushed_at":"2020-02-15T06:41:09.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-13T20:03:46.531Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vaaaaanquish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-13T07:46:53.000Z","updated_at":"2020-03-15T07:21:46.000Z","dependencies_parsed_at":"2023-06-28T17:46:02.669Z","dependency_job_id":null,"html_url":"https://github.com/vaaaaanquish/gokart-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vaaaaanquish/gokart-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaaaaanquish%2Fgokart-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaaaaanquish%2Fgokart-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaaaaanquish%2Fgokart-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaaaaanquish%2Fgokart-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vaaaaanquish","download_url":"https://codeload.github.com/vaaaaanquish/gokart-examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaaaaanquish%2Fgokart-examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265198349,"owners_count":23726447,"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":"2024-11-17T08:29:43.646Z","updated_at":"2025-07-13T20:03:48.773Z","avatar_url":"https://github.com/vaaaaanquish.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gokart-examples\ngokart examples for m3 techbook 2\n\nfor `技術書典8`.\nurl: https://techbookfest.org/event/tbf08/circle/5759156128579584\n\n\n# 1, Make project by cookiecutter-gokart\n\nWe can use project templete by [cookiecutter](https://github.com/cookiecutter/cookiecutter).\n\n```\n$ cookiecutter https://github.com/m3dev/cookiecutter-gokart\nproject_name [project_name]: GokartSample\npackage_name [package_name]: sample\npython_version [3.6]:\nauthor [your name]: vaaaaanquish\npackage_description [What's this project?]: gokart task example\nlicense [MIT License]:\n```\n\n```\n$ tree .\n.\n├── GokartSample\n│   ├── README.md\n│   ├── conf\n│   │   ├── logging.ini\n│   │   └── param.ini\n│   ├── main.py\n│   ├── sample\n│   │   ├── __init__.py\n│   │   └── model\n│   │       ├── __init__.py\n│   │       └── sample.py\n│   ├── setup.py\n│   └── test\n│       └── unit_test\n│           ├── __init__.py\n│           └── test_sample.py\n└── README.md\n```\n\n\nUnittest has already been added :)\n\n\n```\n$ cd GokartSample/\n$ python -m unittest discover -s ./test/unit_test\n.\n----------------------------------------------------------------------\nRan 1 test in 0.001s\n\nOK\n```\nstart test-driven development!\n\n\n\n# 2, Development gokart task\n\nexample: GokartSample/sample/model/sample.py\n - TaskA: dump dict\n - TaskB: update dict\n - TaskC: TasA -\u003e TaskB and update dict\n\n\nTDD. It is a correspondence table between task and test.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003esample/model/sample.py\u003c/th\u003e\n\u003cth\u003etest/unit_test/test_sample.py\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003cpre\u003e\nclass TaskA(gokart.TaskOnKart):\n    sample = luigi.Parameter()\n\n    def run(self):\n        results = {'param_a': 1, 'param_b': self.sample}\n        self.dump(results)\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cpre\u003eclass TestTaskA(unittest.TestCase):\n    def setUp(self):\n        self.task = TaskA(sample=None)\n        self.output_data = None\n\n    def test_run(self):\n        source = 'hoge'\n        target = {'param_a': 1, 'param_b': 'hoge'}\n\n        self.task.sample = source\n        self.task.dump = MagicMock(side_effect=self._dump)\n\n        self.task.run()\n        self.assertDictEqual(self.output_data, target)\n\n    def _dump(self, data):\n        self.output_data = data\n\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cpre\u003eclass TaskB(gokart.TaskOnKart):\n    task = gokart.TaskInstanceParameter()\n\n    def requires(self):\n        return self.task\n\n    def run(self):\n        params = self.load()\n        params.update({'trained': True})  # training model\n        self.dump(params)\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cpre\u003eclass TestTaskB(unittest.TestCase):\n    def setUp(self):\n        self.task = TaskB(task=gokart.TaskOnKart())\n        self.output_data = None\n\n    def test_run(self):\n        source = {'test': 'hoge'}\n        target = {'test': 'hoge', 'trained': True}\n\n        self.task.load = MagicMock(side_effect=lambda: source)\n        self.task.dump = MagicMock(side_effect=self._dump)\n\n        self.task.run()\n        self.assertDictEqual(self.output_data, target)\n\n    def _dump(self, data):\n        self.output_data = data\n\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cpre\u003eclass TaskC(gokart.TaskOnKart):\n    def requires(self):\n        return TaskB(task=self.clone(TaskA, sample='hoge'))\n\n    def run(self):\n        model = self.load()\n        model.update({'task_name': 'task_c'})\n        self.dump(model)\n\u003c/pre\u003e\u003c/td\u003e\n\u003ctd\u003e\u003cpre\u003eclass TestTaskC(unittest.TestCase):\n    def setUp(self):\n        self.task = TaskC()\n        self.output_data = None\n\n    def test_run(self):\n        source = {'test': 'hoge'}\n        target = {'test': 'hoge', 'task_name': 'task_c'}\n\n        self.task.load = MagicMock(side_effect=lambda: source)\n        self.task.dump = MagicMock(side_effect=self._dump)\n\n        self.task.run()\n        self.assertDictEqual(self.output_data, target)\n\n    def _dump(self, data):\n        self.output_data = data\n\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\n \n\n# 3 running gokart\n\nLet's running gokart task.\n```\n# add new parameter info GokartSample/conf/param.ini\n[sample.TaskA]\nsample='sample param'\n```\n\nrun.\n```\n$ python main.py sample.TaskC --local-scheduler\n\n...\n===== Luigi Execution Summary =====\nScheduled 3 tasks of which:\n* 3 ran successfully:\n    - 1 sample.TaskA(...)\n    - 1 sample.TaskB(...)\n    - 1 sample.TaskC(...)\n\nThis progress looks :) because there were no failed tasks or missing dependencies\n\n===== Luigi Execution Summary =====\n```\n↓\ncheck output files\n↓\n```\n$ tree resource\n\nresource/\n├── log\n│   ├── module_versions\n│   │   ├── TaskA_74416d6e12945172d2ae8a4eaa6bc9de.txt\n│   │   ├── TaskB_cb786f70051e31e9f4fcdf2aac06b533.txt\n│   │   └── TaskC_e49eb8498c2ad327e1ca4ead88cea1ad.txt\n│   ├── processing_time\n│   │   ├── TaskA_74416d6e12945172d2ae8a4eaa6bc9de.pkl\n│   │   ├── TaskB_cb786f70051e31e9f4fcdf2aac06b533.pkl\n│   │   └── TaskC_e49eb8498c2ad327e1ca4ead88cea1ad.pkl\n│   ├── task_log\n│   │   ├── TaskA_74416d6e12945172d2ae8a4eaa6bc9de.pkl\n│   │   ├── TaskB_cb786f70051e31e9f4fcdf2aac06b533.pkl\n│   │   └── TaskC_e49eb8498c2ad327e1ca4ead88cea1ad.pkl\n│   └── task_params\n│       ├── TaskA_74416d6e12945172d2ae8a4eaa6bc9de.pkl\n│       ├── TaskB_cb786f70051e31e9f4fcdf2aac06b533.pkl\n│       └── TaskC_e49eb8498c2ad327e1ca4ead88cea1ad.pkl\n└── sample\n    └── model\n        └── sample\n            ├── TaskA_74416d6e12945172d2ae8a4eaa6bc9de.pkl\n            ├── TaskB_cb786f70051e31e9f4fcdf2aac06b533.pkl\n            └── TaskC_e49eb8498c2ad327e1ca4ead88cea1ad.pkl\n\n8 directories, 15 files\n```\n\n\n\n# 3, Check data by thunderbolt\n\nPlease see `./ExampleThunderbolt.ipynb`\n\n```\nfrom thunderbolt import Thunderbolt\ntb = Thunderbolt('./resource')\nprint(tb.get_data(’TaskC’)) # outout TaskC's result\nprint(tb.get_task_df()) # get all task parameter's\n```\n\n# 4, Make Machine Learning Task using redshells\n\nPlease see redshells examples.\n\nhttps://github.com/m3dev/redshells/tree/master/examples\n\n\n# Thanks.\n\n - luigi: https://github.com/spotify/luigi\n - cookiecutter-gokart: https://github.com/m3dev/cookiecutter-gokart\n - gokart: https://github.com/m3dev/gokart\n - thunderbolt: https://github.com/m3dev/thunderbolt\n - redshells: https://github.com/m3dev/redshells\n\nThanks :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaaaaanquish%2Fgokart-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaaaaanquish%2Fgokart-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaaaaanquish%2Fgokart-examples/lists"}