{"id":16507595,"url":"https://github.com/chmp/csc","last_synced_at":"2026-06-08T04:31:40.168Z","repository":{"id":223123080,"uuid":"758823784","full_name":"chmp/csc","owner":"chmp","description":"Execute python scripts cell by cell","archived":false,"fork":false,"pushed_at":"2024-02-18T11:20:27.000Z","size":138,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T15:31:19.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/chmp.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changes.md","contributing":null,"funding":null,"license":"License.md","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}},"created_at":"2024-02-17T07:19:31.000Z","updated_at":"2024-02-18T11:21:22.000Z","dependencies_parsed_at":"2024-02-18T13:39:07.656Z","dependency_job_id":null,"html_url":"https://github.com/chmp/csc","commit_stats":null,"previous_names":["chmp/csc"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmp%2Fcsc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmp%2Fcsc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmp%2Fcsc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmp%2Fcsc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chmp","download_url":"https://codeload.github.com/chmp/csc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241451560,"owners_count":19964900,"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-10-11T15:29:14.919Z","updated_at":"2026-06-08T04:31:35.132Z","avatar_url":"https://github.com/chmp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `csc` -  Execute python scripts cell by cell\n\nInstall with\n\n```bash\npip install csc\n```\n\n## Usage\n\nConsider the following training script\n\n```python\n#: parameters\n...\n\n#: setup\n...\n\n#: train\n...\n\n#: save\n...\n```\n\nTo run the the script cell by cell, use:\n\n```python\nscript = csc.Script(\"experiment.py\")\nscript.run(\"parameters\")\nscript.run(\"setup\")\nscript.run(\"train\")\nscript.run(\"save\")\n```\n\n### Splicing scripts\n\nDifferent scripts can be \"spliced\" together by specifying multiple scripts. The\nfirst script acts as the base script and defines the available cells. Subsequent\nscripts, or spliced scripts, can extend the cells of the base script. All\nscripts share a single scope. For each cell, first the code of the base script\nis executed and then the code of the spliced scripts.\n\n\n```python\n# file: parameters.py\n#: parameters\nbatch_size = ...\n```\n\n```python\nscripts = csc.Script([\"experiment.py\", \"parameters.py\"])\n\n# executes first the 'parameters' cell of 'experiment.py', then the\n# 'parameters' cell of 'parameters.py'\nscripts.run(\"parameters\")\n```\n\n### Command line usage\n\n`csc` include a command line script splice and execute scripts. Usage:\n\n```bash\n$ python -m csc base_script.py spliced_script_1.py spliced_script_2.py\n```\n\nTo splice in parameters, `csc` offers a shortcut: arguments specified via `-p\nSTATEMENT` are concatenated into a script with a single 'parameters' cell that\nexecutes the given statements.\n\n```bash\n# this call\n$ python -m csc base_script.py -p batch_size=100 -p learning_rate=3e-4\n\n# is equivalent to\n$ python -m csc base_script.py parameters.py\n$ cat parameters.py\n#: parameters\nbatch_size=100\nlearning_rate=3e-4\n```\n\n## API Reference\n\n\u003c!-- minidoc \"function\": \"csc.Script\", \"header_depth\": 3 --\u003e\n### `csc.Script(base_script: Union[str, pathlib.Path, FileSource, InlineSource], /, *spliced_scripts, cell_marker: str = '#:', register: bool = False)`\n\n[csc.Script]: #cscscriptbase_script-unionstr-pathlibpath-filesource-inlinesource-/-spliced_scripts-cell_marker-str--#-register-bool--false\n\nA Python script that can be executed cell by cell\n\nCells are defined via comments (per default '#: {CELL_NAME}').\n\n#### `csc.Script.list(self) -\u003e list[str]`\n\n[csc.Script.list]: #cscscriptlistself---liststr\n\nList all cells of the script\n\nOnly cells of the base script are considered.\n\n#### `csc.Script.run(self, *cell_names) -\u003e None`\n\n[csc.Script.run]: #cscscriptrunself-cell_names---none\n\nRun cells of the script by name\n\n#### `csc.Script.eval(self, expr: str) -\u003e Any`\n\n[csc.Script.eval]: #cscscriptevalself-expr-str---any\n\nEvaluate an expression the scope of the script\n\n\u003c!-- minidoc --\u003e\n\n\u003c!-- minidoc \"function\": \"csc.FileSource\", \"header_depth\": 3 --\u003e\n### `csc.FileSource(path: pathlib.Path, *, cell_marker: str)`\n\n[csc.FileSource]: #cscfilesourcepath-pathlibpath--cell_marker-str\n\nDefine a script via a file\n\n\u003c!-- minidoc --\u003e\n\n\u003c!-- minidoc \"function\": \"csc.InlineSource\", \"header_depth\": 3 --\u003e\n### `csc.InlineSource(text: str, *, cell_marker: str)`\n\n[csc.InlineSource]: #cscinlinesourcetext-str--cell_marker-str\n\nDefine a script via its source\n\n\u003c!-- minidoc --\u003e\n\n## License\n\nThis package is licensed under the MIT License. See `LICENSE` for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchmp%2Fcsc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchmp%2Fcsc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchmp%2Fcsc/lists"}