{"id":23449119,"url":"https://github.com/oeway/ailabpython","last_synced_at":"2025-04-10T02:37:55.148Z","repository":{"id":62566335,"uuid":"64128986","full_name":"oeway/AILabPython","owner":"oeway","description":"Python toolkits for connecting AILab platform","archived":false,"fork":false,"pushed_at":"2017-02-10T09:48:15.000Z","size":90,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T18:32:46.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ai.pasteur.fr","language":"Python","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/oeway.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}},"created_at":"2016-07-25T11:30:37.000Z","updated_at":"2017-02-11T09:10:59.000Z","dependencies_parsed_at":"2022-11-03T16:15:30.469Z","dependency_job_id":null,"html_url":"https://github.com/oeway/AILabPython","commit_stats":null,"previous_names":["oeway/distributedai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabPython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabPython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabPython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabPython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oeway","download_url":"https://codeload.github.com/oeway/AILabPython/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144659,"owners_count":21054966,"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-12-23T22:20:06.658Z","updated_at":"2025-04-10T02:37:55.127Z","avatar_url":"https://github.com/oeway.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Toolkits for AILab platform (WIP)\n\nPython toolkits for connecting AILab platform(http://ai.pasteur.fr), the following module are included:\n## `dai.Worker`\nThe worker for communicating with [AILab platform](http://ai.pasteur.fr) and executing tasks defined by widget.\n## `dai.taskProcessors`\nA set of predefined taskProcessor to exectue tasks, three type of taskProcessors are implemented:\n * `TaskProcessor`, the base class, implement a plain task processor\n * `ThreadedTaskProcessor`, a task process executed in a seperate thread\n * `ProcessTaskProcessor`, a task process executed as a subprocess, it can be any commandline program which support commandline arguments and print information as output.\n\n# Installation\nRun the following command to install:\n```bash\npip install dai\n```\nThat's it.\n\n# Getting Start\nYou need to login to [AILab platform](http://ai.pasteur.fr) and then goto \"Widget Workers\", create a new worker, and get the id and token.\n\nAs an example, we get a worker `id=iJX99fYEdfasigEAd` and `token=jguogvqlerkygcc`.\n\nThen, to run the actual worker, you can open a python prompt session and type the following commands:\n\n```python\nimport dai\n\nworker_id='iJX99fYEdfasigEAd'\nworker_token='jguogvqlerkygcc'\nworkdir='./dai-workdir'\n\nd = dai.Worker(worker_id=worker_id,\n               worker_token=worker_token,\n               server_url='wss://ai.pasteur.fr/websocket',\n               workdir=workdir,\n               dev_mode=True)\nd.start()\n```\nAnd you will see the worker running on the platform, now you are ready to go, try to create a widget and add the worker you just created. In the \"Code\" tab in a widget editor, you can add one code file named \"__init__.py\" with the type \"python\" which will perform the actuall task on the worker node.\n\nHere is an example of task processor code which uses Keras for training networks:\n```python\nfrom dai.kerasUtils import KerasProcess\n\nclass Process(KerasProcess):\n    def task_arguments(self):\n        x = self.task.get('input.x')\n        return ['python', 'test.py', x]\n\nif __name__ == \"__worker__\":\n    TASK_PROCESSOR = Process(TASK, WIDGET, WORKER)\n```\n\nA task processor code example:\n```python\nfrom dai.taskProcessors import ProcessTaskProcessor\nclass MyProcess(ProcessTaskProcessor):\n    def task_arguments(self):\n        x = self.task.get('input.x')\n        return ['python', 'test.py', x]\n\n    def process_output(self, line):\n        print(line)\n\nif __name__ == \"__worker__\":\n    TASK_PROCESSOR = MyProcess(TASK, WIDGET, WORKER)\n```\nAnother task processor code example:\n```python\nimport time\nfrom dai.taskProcessors import ThreadedTaskProcessor\n\ndef process_task(task, **kwargs):\n    # start task\n    task.set(\"status.stage\", \"started\")\n\n    # run your task code with config and input\n    # get task config and input\n    print(task.get(\"config\"))\n    print(task.get(\"input\"))\n\n    # use \"set\" for important information such as error and results\n    task.set({\"status.error\":\"this is a fake error\",\n              \"status.info\":\"error\"})\n\n    # use \"update\" for fast updating intermediate status\n    task.update({\"status.info\": \"hello from worker\",\n                 \"status.progress\": 50})\n\n    time.sleep(3)\n\n    # save result in \"output\"\n    task.set(\"output.result\", 100)\n\n    # finish task\n    task.set(\"status.progress\", 100)\n    task.set(\"status.stage\", \"done\")\n\nif __name__ == \"__worker__\":\n    TASK_PROCESSOR = ThreadedTaskProcessor(TASK, WIDGET, WORKER, process=process_task)\n```\n\nJust fill your code which does some job into `process_task` function. With self.task, you can get the dictionaries which stores the `config`, `input` and `output`. The basic guideline is you let the store the configurations or parameters in `config` dictionary, the file path or the url of your data you want to process in `input` dictionary, after executing your task, fill `output` dictionary with the output.\n\nYou may also want to use HTML and JS to create some awsome GUI for the user to interact, just try to fill PANEL.html and PANEL.js with some code, it uses [AngularJS](https://angularjs.org/) and [Angular-Material](https://material.angularjs.org/latest/) as its underlying implementation.\n\nMore examples and details to be continue...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeway%2Failabpython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foeway%2Failabpython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeway%2Failabpython/lists"}