Merge branch '18631-shell-login-sync'
[arvados.git] / sdk / cwl / arvados_cwl / context.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 from cwltool.context import LoadingContext, RuntimeContext
6 from collections import namedtuple
7
8 class ArvLoadingContext(LoadingContext):
9     def __init__(self, kwargs=None):
10         super(ArvLoadingContext, self).__init__(kwargs)
11
12 class ArvRuntimeContext(RuntimeContext):
13     def __init__(self, kwargs=None):
14         self.work_api = None
15         self.extra_reffiles = []
16         self.priority = 500
17         self.enable_reuse = True
18         self.runnerjob = ""
19         self.submit_request_uuid = None
20         self.project_uuid = None
21         self.trash_intermediate = False
22         self.intermediate_output_ttl = 0
23         self.update_workflow = ""
24         self.create_workflow = False
25         self.submit_runner_ram = 0
26         self.ignore_docker_for_reuse = False
27         self.submit = True
28         self.submit_runner_image = None
29         self.wait = True
30         self.cwl_runner_job = None
31         self.storage_classes = "default"
32         self.intermediate_storage_classes = "default"
33         self.current_container = None
34         self.http_timeout = 300
35         self.submit_runner_cluster = None
36         self.cluster_target_id = 0
37         self.always_submit_runner = False
38         self.collection_cache_size = 256
39         self.match_local_docker = False
40         self.enable_preemptible = None
41
42         super(ArvRuntimeContext, self).__init__(kwargs)
43
44         if self.submit_request_uuid:
45             self.submit_runner_cluster = self.submit_request_uuid[0:5]
46
47     def get_outdir(self) -> str:
48         """Return self.outdir or create one with self.tmp_outdir_prefix."""
49         return self.outdir
50
51     def get_tmpdir(self) -> str:
52         """Return self.tmpdir or create one with self.tmpdir_prefix."""
53         return self.tmpdir
54
55     def create_tmpdir(self) -> str:
56         """Return self.tmpdir or create one with self.tmpdir_prefix."""
57         return self.tmpdir