{"id":23449168,"url":"https://github.com/oeway/ailabnode","last_synced_at":"2025-08-27T09:41:55.747Z","repository":{"id":138962375,"uuid":"81641964","full_name":"oeway/AILabNode","owner":"oeway","description":"an AILab worker with node.js","archived":false,"fork":false,"pushed_at":"2017-06-14T09:39:06.000Z","size":73,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T17:44:47.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","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":"LICENSE","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,"zenodo":null}},"created_at":"2017-02-11T08:59:03.000Z","updated_at":"2017-09-07T01:36:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a2f4370-8672-410f-961b-31eb21e30547","html_url":"https://github.com/oeway/AILabNode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oeway/AILabNode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabNode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabNode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabNode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabNode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oeway","download_url":"https://codeload.github.com/oeway/AILabNode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeway%2FAILabNode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272315570,"owners_count":24912599,"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","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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:41.436Z","updated_at":"2025-08-27T09:41:55.729Z","avatar_url":"https://github.com/oeway.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js Toolkits for AILab platform (WIP)\n\n# Installation\n\nStep 1: you will need to install nodejs(https://nodejs.org/).\n\nFor linux user:\n```bash\necho 'export PATH=$HOME/local/bin:$PATH' \u003e\u003e ~/.bashrc\n. ~/.bashrc\nmkdir ~/local\ncd ~/local\n# nodejs binaries: https://nodejs.org/download/release/latest-v7.x/\ncurl https://nodejs.org/download/release/latest-v7.x/node-v7.9.0-linux-x64.tar.gz | tar --strip-components 1 -xzv\n# check whether node and npm is available\nwhich node \u0026\u0026 which npm\n```\nYou should be able to see the following outputs, which means nodejs is now ready:\n```\n~/local/bin/node\n~/local/bin/npm\n```\n\nStep 2: install AILabNode:\n```bash\ngit clone https://github.com/oeway/AILabNode.git\ncd AILabNode\n\n# if the following doesn't work, you need to run `export PATH=$HOME/local/bin:$PATH` and run it again.\nnpm install\n```\n\nIf you have problem with node or npm from the step 1, try to run the following commands to compile nodejs from source(you will need gcc/4.9):\n```bash\nsh ./install_node.sh\nnpm install\n```\n\n# Getting Start\nYou need to login to AILab.AI platform and then goto \"Widget Workers\", create a new worker, and get the id and token.\n\nAs an example, we get a worker `id=iJX99fYEdfasigEAe` and `token=jguogvqlerkygcc`, we will use them as arguments for the worker scripts.\n\nThen, to run the actual worker, you can open a terminal window and type the following commands:\n```bash\n# start worker\nnode index.js --id iJX99fYEdfasigEAe --token jguogvqlerkygcc\n```\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 \"WORKER.js\" with the type \"javascript\" which will perform the actuall task on the worker node.\n\n```js\n$ctrl.run = function(){\n    const cmd = 'python';\n    const args = ['-c', 'print(\"hello world\")'];\n\n    $ctrl.process = child_process.spawn(cmd, args, {cwd:$ctrl.task.workdir});\n    $ctrl.process.stdout.on('data', (data)=\u003e{\n      console.log(data.toString());\n      // parse the console output here\n      $ctrl.task.set({'status.info': data.toString()});\n    });\n    $ctrl.process.on('error', (e)=\u003e{\n      console.error(e.toString());\n      $ctrl.task.set({'status.error': e.toString()});\n    });\n}\n$ctrl.stop = function(){\n    $ctrl.process.kill();\n}\n```\n\n# The 3-way binding of the `$ctrl.task` object\nTo enable a simple and seamless communication between the web GUI and the worker, AILab has an javascript object which is synchronized in real-time between the web GUI, the server database and the worker(3-way binding). It's a json object can be accessed with `$ctrl.task`, and has the following structure:\n```json\n{\n\"name\": \"my task\",\n\"config\": {},\n\"input\": {},\n\"output\": {},\n\"status\": {\n  \"stage\":\"loading\",\n  \"progress\": 55,\n  \"running\": true,\n  \"info\": \"\",\n  \"error\": \"\"\n  }\n}\n```\nGenerally, you can change any of the above fields by using `$ctrl.task.set(key, value)` syntax, but they are designed for different purposes. Here is a general guide for using these fields:\n * use `$ctrl.task.config` for saving and updating settings, configurations of the task.\n * use `$ctrl.task.input` for the input of the task, usually, it can be a file path, an url, some numbers or string which generate by another task.\n * use `$ctrl.task.output` for the output of the task, it can be a file path or url, some numbers or string produced by the task.\n * the fields in `$ctrl.task.status` is fixed and they are linked to the default GUI, so for example, you can change `$ctrl.task.status.progress` to change the display a progress bar showed in your task. Similarly, you can show some infomation or error message with `$ctrl.task.status.info` and `$ctrl.task.status.error`.\n * use `$ctrl.task.set(key, value)` to set one field, for example: `$ctrl.task.set(\"status.progress\", 45);`.\n * use `$ctrl.task.set({key1:value1, key2:value2})` to set multiple fields, for example `$ctrl.task.set({\"status.error\":\"open file error\", \"input.file\": \"XX.png\"})`\n * use `$ctrl.task.get(key)` syntax to get value, for example: `var x = $ctrl.task.get(\"config.x\");`\n \nOnce you set the variables, it will be synchronized across all the web pages and the worker in real-time, it's a reactive 3-way binding.\nSo it will enables you to take input form the web GUI and use it immediately on the worker. For example:\nIn the `PANEL.html`, you have:\n```html\nx: \u003cinput type=\"number\" ng-model=\"$ctrl.task.config.x\"\u003e\ny: {{$ctrl.task.output.y}}\n```\nAnd you can do this in the `WORKER.js`:\n```javascript\nx = $ctrl.task.get('config.x');\ny = x*23+8;\n\n$ctrl.task.set('output.y', y);\n// then you should be able to see the updated y on your web GUI.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeway%2Failabnode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foeway%2Failabnode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeway%2Failabnode/lists"}