{"id":19080266,"url":"https://github.com/clemos/factory-production-line-exercise","last_synced_at":"2026-07-04T00:32:42.347Z","repository":{"id":227501603,"uuid":"771605527","full_name":"clemos/factory-production-line-exercise","owner":"clemos","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-13T15:59:59.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-22T05:42:26.245Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clemos.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":"2024-03-13T15:54:29.000Z","updated_at":"2024-03-13T15:56:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"09aeb16f-d70b-45a5-a629-ffda61f6f46b","html_url":"https://github.com/clemos/factory-production-line-exercise","commit_stats":null,"previous_names":["clemos/factory-production-line-exercise"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clemos/factory-production-line-exercise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clemos%2Ffactory-production-line-exercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clemos%2Ffactory-production-line-exercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clemos%2Ffactory-production-line-exercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clemos%2Ffactory-production-line-exercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clemos","download_url":"https://codeload.github.com/clemos/factory-production-line-exercise/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clemos%2Ffactory-production-line-exercise/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35106552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"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-11-09T02:18:13.669Z","updated_at":"2026-07-04T00:32:42.325Z","avatar_url":"https://github.com/clemos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Factory Production Line Exercise\n\n## Usage\n\nJust:\n```\npython production-line.py\n```\n\nWill output a log of the production line activity to `stdout` in the form of a list of events.\n\nEach event corresponds to the time of completion of one of more robot tasks\n\nEach event starts with a `---` line, and outputs\n1. current event time\n2. number of resources available to the production line (foo, bar, foobar, money and robots)\n3. list of ongoing robot tasks with their current timeout\n4. list of robots who completed their tasks during this event, and which new task they have been assigned to next\n\nSample event:\n```\n---\ntime = 664.2953750876165,\nfoo = 3, bar = 3, foobar = 3, money = 2, robots = 29\n        -\u003e buy robot (timeout 0.45079961324662854)\n        -\u003e buy robot (timeout 10.12365989839571)\n        -\u003e assemble foobar (timeout 9.988049260943589)\n        -\u003e assemble foobar (timeout 5.701984232964747)\n        -\u003e assemble foobar (timeout 3.4225624714551035)\n        -\u003e assemble foobar (timeout 10.223090968089837)\n        -\u003e assemble foobar (timeout 3.2982013540256485)\n        -\u003e buy robot (timeout 1.1888534054865563)\n        -\u003e assemble foobar (timeout 3.441316441095987)\n        -\u003e assemble foobar (timeout 7.95204148618909)\n        -\u003e assemble foobar (timeout 3.2820471140257386)\n        -\u003e assemble foobar (timeout 9.441316441095983)\n        -\u003e mining bar (timeout 1.1556967168451762)\n        -\u003e assemble foobar (timeout 3.3152091647374267)\n        -\u003e assemble foobar (timeout 4.1728258007983055)\n        -\u003e assemble foobar (timeout 3.7088993843576485)\n        -\u003e assemble foobar (timeout 3.422975996010754)\n        -\u003e assemble foobar (timeout 9.952041486189094)\n        -\u003e assemble foobar (timeout 3.9939096476893403)\n        -\u003e buy robot (timeout 1.3165147439626868)\n        -\u003e assemble foobar (timeout 3.441316441095987)\n        -\u003e assemble foobar (timeout 3.8813383944762854)\n        -\u003e assemble foobar (timeout 4.005674230980377)\n        -\u003e assemble foobar (timeout 3.738698573596052)\n        -\u003e sell 5 foobar(s) (timeout 0.47900642924703796)\n        -\u003e assemble foobar (timeout 3.9520414861890933)\n        -\u003e assemble foobar (timeout 3.3031204534837055)\n        -\u003e assemble foobar (timeout 4.223090968089837)\n        -\u003e mining bar (timeout 1.0052341122803732)\nrobot #0\n        ending: buy robot (timeout 0.0)\n        new task: mining bar (timeout 1.1250158297220478)\n```\n\nEventually, the script should output `finished generating 30 robots !` and exit.\n\n## Notes\n\nThe script mainly instantiates a `ProductionLine`, with:\n* `min_robots=2`: number of robots at beginning\n* `max_robots=30`: number of robots to reach the end\n\n`ProductionLine.tasks` represents the Production Line robots, and is just a list of ongoing tasks.\n\nWhen calling `ProductionLine.start()`, the initial robots will be created (i.e. their tasks selected and started)\nand `ProductionLine.next_tick()` will be called until the expected number of robots is reached\n\nWithin `ProductionLine.next_tick()`, we will:\n* find the next ending task (the one with the lowest `timeout`)\n* increment internal time to reach this ending, and update all tasks `timeout` accordingly\n* end tasks that were completed, and select new tasks to start\n\n`ProductionLine.select_next_task()` is the method that implements the business algorithm, i.e. the method responsible for\nselecting the next task for a new robot, or for a robot who completed its task.\n\nEach robot task is implemented by extending the `Task` class, overriding:\n* `timeout`: the task duration; can be computed/overwritten during start()\n* `start()`: start the task, typically by consuming resources from the `state` (i.e. production line) if required\n* `end()`: end the task, typically by adding resources to the `state`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclemos%2Ffactory-production-line-exercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclemos%2Ffactory-production-line-exercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclemos%2Ffactory-production-line-exercise/lists"}