Merge branch '21990-log-timestamps'
[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         self.default_docker_image = None
11         super(ArvLoadingContext, self).__init__(kwargs)
12
13 class ArvRuntimeContext(RuntimeContext):
14     def __init__(self, kwargs=None):
15         self.work_api = None
16         self.extra_reffiles = []
17         self.priority = 500
18         self.enable_reuse = True
19         self.runnerjob = ""
20         self.submit_request_uuid = None
21         self.project_uuid = None
22         self.trash_intermediate = False
23         self.intermediate_output_ttl = 0
24         self.update_workflow = ""
25         self.create_workflow = False
26         self.submit_runner_ram = 0
27         self.ignore_docker_for_reuse = False
28         self.submit = True
29         self.submit_runner_image = None
30         self.wait = True
31         self.cwl_runner_job = None
32         self.storage_classes = "default"
33         self.intermediate_storage_classes = "default"
34         self.current_container = None
35         self.http_timeout = 300
36         self.submit_runner_cluster = None
37         self.cluster_target_id = 0
38         self.always_submit_runner = False
39         self.collection_cache_size = 256
40         self.match_local_docker = False
41         self.enable_preemptible = None
42         self.enable_resubmit_non_preemptible = None
43         self.copy_deps = None
44         self.defer_downloads = False
45         self.varying_url_params = ""
46         self.prefer_cached_downloads = False
47         self.cached_docker_lookups = {}
48         self.print_keep_deps = False
49         self.git_info = {}
50         self.enable_usage_report = None
51         self.usage_report_notes = []
52
53         super(ArvRuntimeContext, self).__init__(kwargs)
54
55         if self.submit_request_uuid:
56             self.submit_runner_cluster = self.submit_request_uuid[0:5]
57
58     def get_outdir(self) -> str:
59         """Return self.outdir or create one with self.tmp_outdir_prefix."""
60         return self.outdir
61
62     def get_tmpdir(self) -> str:
63         """Return self.tmpdir or create one with self.tmpdir_prefix."""
64         return self.tmpdir
65
66     def create_tmpdir(self) -> str:
67         """Return self.tmpdir or create one with self.tmpdir_prefix."""
68         return self.tmpdir