|
| 1 | +import datetime |
| 2 | + |
| 3 | +import strawberry |
| 4 | +from strawberry.types import Info |
| 5 | + |
| 6 | +from db.python.layers.analysis_runner import AnalysisRunnerLayer |
| 7 | +from models.models.analysis_runner import AnalysisRunnerInternal |
| 8 | + |
| 9 | + |
| 10 | +@strawberry.type |
| 11 | +class AnalysisRunnerMutations: |
| 12 | + """Analysis Runner mutations""" |
| 13 | + |
| 14 | + @strawberry.mutation |
| 15 | + async def create_analysis_runner_log( # pylint: disable=too-many-arguments |
| 16 | + self, |
| 17 | + ar_guid: str, |
| 18 | + access_level: str, |
| 19 | + repository: str, |
| 20 | + commit: str, |
| 21 | + script: str, |
| 22 | + description: str, |
| 23 | + driver_image: str, |
| 24 | + config_path: str, |
| 25 | + environment: str, |
| 26 | + batch_url: str, |
| 27 | + submitting_user: str, |
| 28 | + meta: strawberry.scalars.JSON, |
| 29 | + output_path: str, |
| 30 | + hail_version: str | None, |
| 31 | + cwd: str | None, |
| 32 | + info: Info, |
| 33 | + ) -> str: |
| 34 | + """Create a new analysis runner log""" |
| 35 | + # TODO Reconfigure connection permissions as per `routes` |
| 36 | + connection = info.context['connection'] |
| 37 | + alayer = AnalysisRunnerLayer(connection) |
| 38 | + |
| 39 | + if not connection.project: |
| 40 | + raise ValueError('Project not set') |
| 41 | + |
| 42 | + analysis_id = await alayer.insert_analysis_runner_entry( |
| 43 | + AnalysisRunnerInternal( |
| 44 | + ar_guid=ar_guid, |
| 45 | + timestamp=datetime.datetime.now(), |
| 46 | + access_level=access_level, |
| 47 | + repository=repository, |
| 48 | + commit=commit, |
| 49 | + script=script, |
| 50 | + description=description, |
| 51 | + driver_image=driver_image, |
| 52 | + config_path=config_path, |
| 53 | + cwd=cwd, |
| 54 | + environment=environment, |
| 55 | + hail_version=hail_version, |
| 56 | + batch_url=batch_url, |
| 57 | + submitting_user=submitting_user, |
| 58 | + meta=meta, |
| 59 | + project=connection.project, |
| 60 | + audit_log_id=None, |
| 61 | + output_path=output_path, |
| 62 | + ) |
| 63 | + ) |
| 64 | + |
| 65 | + return analysis_id |
0 commit comments