Wrap an external ``solution.py`` file as a Solution dict.
(definition: dict, solution_py: Path)
| 137 | |
| 138 | |
| 139 | def build_custom_solution(definition: dict, solution_py: Path) -> dict: |
| 140 | """Wrap an external ``solution.py`` file as a Solution dict.""" |
| 141 | name = definition["name"] |
| 142 | code = solution_py.read_text() |
| 143 | dps = _infer_dps(code, definition) |
| 144 | code = code.replace("stream", "strm") |
| 145 | |
| 146 | return { |
| 147 | "name": f"custom_{name}", |
| 148 | "definition": name, |
| 149 | "author": "run_dataset", |
| 150 | "description": f"Custom solution from {solution_py.name}.", |
| 151 | "spec": { |
| 152 | "languages": ["pytorch"], |
| 153 | "target_hardware": ["LOCAL"], |
| 154 | "entry_point": "solution.py::run", |
| 155 | "dependencies": ["torch"], |
| 156 | "destination_passing_style": dps, |
| 157 | }, |
| 158 | "sources": [ |
| 159 | { |
| 160 | "path": "solution.py", |
| 161 | "content": code, |
| 162 | } |
| 163 | ], |
| 164 | } |
| 165 | |
| 166 | |
| 167 | def build_reference_solution(definition: dict) -> dict: |
no test coverage detected