fluidattacks_batch_client 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. fluidattacks_batch_client-0.1.0/.envrc +2 -0
  2. fluidattacks_batch_client-0.1.0/PKG-INFO +9 -0
  3. fluidattacks_batch_client-0.1.0/build/default.nix +13 -0
  4. fluidattacks_batch_client-0.1.0/build/filter.nix +12 -0
  5. fluidattacks_batch_client-0.1.0/flake.lock +341 -0
  6. fluidattacks_batch_client-0.1.0/flake.nix +29 -0
  7. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/__init__.py +9 -0
  8. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/_cli.py +171 -0
  9. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/_logger.py +17 -0
  10. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/_utils.py +102 -0
  11. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/api/__init__.py +11 -0
  12. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/api/_client_1/__init__.py +36 -0
  13. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/api/_client_1/_get_command.py +68 -0
  14. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/api/_client_1/_list_jobs.py +123 -0
  15. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/api/_client_1/_send_job.py +189 -0
  16. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/api/_core.py +33 -0
  17. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/core.py +310 -0
  18. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/decode.py +175 -0
  19. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/py.typed +0 -0
  20. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/sender/__init__.py +15 -0
  21. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/sender/_core.py +26 -0
  22. fluidattacks_batch_client-0.1.0/fluidattacks_batch_client/sender/_send.py +87 -0
  23. fluidattacks_batch_client-0.1.0/mypy.ini +30 -0
  24. fluidattacks_batch_client-0.1.0/pyproject.toml +30 -0
  25. fluidattacks_batch_client-0.1.0/tests/__init__.py +0 -0
  26. fluidattacks_batch_client-0.1.0/tests/arch/__init__.py +0 -0
  27. fluidattacks_batch_client-0.1.0/tests/arch/arch.py +50 -0
  28. fluidattacks_batch_client-0.1.0/tests/arch/test_arch.py +42 -0
  29. fluidattacks_batch_client-0.1.0/tests/py.typed +0 -0
  30. fluidattacks_batch_client-0.1.0/uv.lock +764 -0
@@ -0,0 +1,2 @@
1
+ ln -f ../mypy.ini ./mypy.ini
2
+ use_flake ".#python311.devShell"
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: fluidattacks_batch_client
3
+ Version: 0.1.0
4
+ Summary: AWS batch python client
5
+ Author-email: Engineering Team <development@fluidattacks.com>
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: click >=8.1.8, <9.0.0
8
+ Requires-Dist: boto3 >=1.42.32, <2.0.0
9
+ Requires-Dist: fa_purity >=2.5.0, <3.0.0
@@ -0,0 +1,13 @@
1
+ {
2
+ nixpkgs,
3
+ builders,
4
+ scripts,
5
+ src,
6
+ }:
7
+ {
8
+ inherit src;
9
+ root_path = "observes/common/batch-client";
10
+ module_name = "fluidattacks_batch_client";
11
+ pypi_token_var = "BATCH_CLIENT_TOKEN";
12
+ override = b: b;
13
+ }
@@ -0,0 +1,12 @@
1
+ path_filter: src:
2
+ path_filter {
3
+ root = src;
4
+ include = [
5
+ "fluidattacks_batch_client"
6
+ "tests"
7
+ "pyproject.toml"
8
+ "mypy.ini"
9
+ "ruff.toml"
10
+ "uv.lock"
11
+ ];
12
+ }
@@ -0,0 +1,341 @@
1
+ {
2
+ "nodes": {
3
+ "flake-parts": {
4
+ "inputs": {
5
+ "nixpkgs-lib": "nixpkgs-lib"
6
+ },
7
+ "locked": {
8
+ "lastModified": 1762810396,
9
+ "narHash": "sha256-dxFVgQPG+R72dkhXTtqUm7KpxElw3u6E+YlQ2WaDgt8=",
10
+ "owner": "hercules-ci",
11
+ "repo": "flake-parts",
12
+ "rev": "0bdadb1b265fb4143a75bd1ec7d8c915898a9923",
13
+ "type": "github"
14
+ },
15
+ "original": {
16
+ "owner": "hercules-ci",
17
+ "repo": "flake-parts",
18
+ "type": "github"
19
+ }
20
+ },
21
+ "nix_filter": {
22
+ "locked": {
23
+ "lastModified": 1757882181,
24
+ "narHash": "sha256-+cCxYIh2UNalTz364p+QYmWHs0P+6wDhiWR4jDIKQIU=",
25
+ "owner": "numtide",
26
+ "repo": "nix-filter",
27
+ "rev": "59c44d1909c72441144b93cf0f054be7fe764de5",
28
+ "type": "github"
29
+ },
30
+ "original": {
31
+ "owner": "numtide",
32
+ "repo": "nix-filter",
33
+ "type": "github"
34
+ }
35
+ },
36
+ "nixpkgs": {
37
+ "locked": {
38
+ "lastModified": 1758690382,
39
+ "narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=",
40
+ "owner": "nixos",
41
+ "repo": "nixpkgs",
42
+ "rev": "e643668fd71b949c53f8626614b21ff71a07379d",
43
+ "type": "github"
44
+ },
45
+ "original": {
46
+ "owner": "nixos",
47
+ "ref": "nixos-unstable",
48
+ "repo": "nixpkgs",
49
+ "type": "github"
50
+ }
51
+ },
52
+ "nixpkgs-lib": {
53
+ "locked": {
54
+ "lastModified": 1761765539,
55
+ "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
56
+ "owner": "nix-community",
57
+ "repo": "nixpkgs.lib",
58
+ "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
59
+ "type": "github"
60
+ },
61
+ "original": {
62
+ "owner": "nix-community",
63
+ "repo": "nixpkgs.lib",
64
+ "type": "github"
65
+ }
66
+ },
67
+ "nixpkgs_2": {
68
+ "locked": {
69
+ "lastModified": 1758690382,
70
+ "narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=",
71
+ "owner": "nixos",
72
+ "repo": "nixpkgs",
73
+ "rev": "e643668fd71b949c53f8626614b21ff71a07379d",
74
+ "type": "github"
75
+ },
76
+ "original": {
77
+ "owner": "nixos",
78
+ "ref": "nixos-unstable",
79
+ "repo": "nixpkgs",
80
+ "type": "github"
81
+ }
82
+ },
83
+ "nixpkgs_3": {
84
+ "locked": {
85
+ "lastModified": 1761373498,
86
+ "narHash": "sha256-Q/uhWNvd7V7k1H1ZPMy/vkx3F8C13ZcdrKjO7Jv7v0c=",
87
+ "owner": "nixos",
88
+ "repo": "nixpkgs",
89
+ "rev": "6a08e6bb4e46ff7fcbb53d409b253f6bad8a28ce",
90
+ "type": "github"
91
+ },
92
+ "original": {
93
+ "owner": "nixos",
94
+ "ref": "nixos-unstable",
95
+ "repo": "nixpkgs",
96
+ "type": "github"
97
+ }
98
+ },
99
+ "nixpkgs_flake": {
100
+ "locked": {
101
+ "lastModified": 1762812764,
102
+ "narHash": "sha256-MNqrovkO8AEQeYQK7e3X2GDx2H8vfDIxV4K/VEaIjjo=",
103
+ "owner": "nixos",
104
+ "repo": "nixpkgs",
105
+ "rev": "400156fe527ab6b54cf6f70cca2c8385548a29c4",
106
+ "type": "github"
107
+ },
108
+ "original": {
109
+ "owner": "nixos",
110
+ "repo": "nixpkgs",
111
+ "type": "github"
112
+ }
113
+ },
114
+ "nixpkgs_flake_2": {
115
+ "locked": {
116
+ "lastModified": 1761668286,
117
+ "narHash": "sha256-YN/cm/hbm7pi7lMZCsNhu6jlBUi4wUirrIlyOMpbjKU=",
118
+ "owner": "nixos",
119
+ "repo": "nixpkgs",
120
+ "rev": "1fdb9eb10eff581a40ce2e9511c4ed517eac0c3f",
121
+ "type": "github"
122
+ },
123
+ "original": {
124
+ "owner": "nixos",
125
+ "repo": "nixpkgs",
126
+ "type": "github"
127
+ }
128
+ },
129
+ "observes_flake_builder": {
130
+ "inputs": {
131
+ "nix_filter": "nix_filter",
132
+ "nixpkgs_flake": "nixpkgs_flake",
133
+ "pyproject-build-systems": "pyproject-build-systems",
134
+ "pyproject-nix": "pyproject-nix_2",
135
+ "pythonix_flake": "pythonix_flake",
136
+ "shell-helpers": "shell-helpers",
137
+ "uv2nix": "uv2nix_2"
138
+ },
139
+ "locked": {
140
+ "dir": "observes/common/std_flake_2",
141
+ "lastModified": 1768584843,
142
+ "narHash": "sha256-V0sEDoOEkxvnG6po+3Ve6OAqFA9H9SuvchW8ohY22Xo=",
143
+ "ref": "refs/heads/trunk",
144
+ "rev": "3fa54e41d48bd54a59a76f3b0495998663758538",
145
+ "shallow": true,
146
+ "type": "git",
147
+ "url": "ssh://git@gitlab.com/fluidattacks/universe"
148
+ },
149
+ "original": {
150
+ "dir": "observes/common/std_flake_2",
151
+ "rev": "3fa54e41d48bd54a59a76f3b0495998663758538",
152
+ "shallow": true,
153
+ "type": "git",
154
+ "url": "ssh://git@gitlab.com/fluidattacks/universe"
155
+ }
156
+ },
157
+ "pyproject-build-systems": {
158
+ "inputs": {
159
+ "nixpkgs": "nixpkgs",
160
+ "pyproject-nix": "pyproject-nix",
161
+ "uv2nix": "uv2nix"
162
+ },
163
+ "locked": {
164
+ "lastModified": 1761781027,
165
+ "narHash": "sha256-YDvxPAm2WnxrznRqWwHLjryBGG5Ey1ATEJXrON+TWt8=",
166
+ "owner": "pyproject-nix",
167
+ "repo": "build-system-pkgs",
168
+ "rev": "795a980d25301e5133eca37adae37283ec3c8e66",
169
+ "type": "github"
170
+ },
171
+ "original": {
172
+ "owner": "pyproject-nix",
173
+ "repo": "build-system-pkgs",
174
+ "type": "github"
175
+ }
176
+ },
177
+ "pyproject-nix": {
178
+ "inputs": {
179
+ "nixpkgs": [
180
+ "observes_flake_builder",
181
+ "pyproject-build-systems",
182
+ "nixpkgs"
183
+ ]
184
+ },
185
+ "locked": {
186
+ "lastModified": 1758265079,
187
+ "narHash": "sha256-amLaLNwKSZPShQHzfgmc/9o76dU8xzN0743dWgvYlr8=",
188
+ "owner": "nix-community",
189
+ "repo": "pyproject.nix",
190
+ "rev": "02e9418fd4af638447dca4b17b1280da95527fc9",
191
+ "type": "github"
192
+ },
193
+ "original": {
194
+ "owner": "nix-community",
195
+ "repo": "pyproject.nix",
196
+ "type": "github"
197
+ }
198
+ },
199
+ "pyproject-nix_2": {
200
+ "inputs": {
201
+ "nixpkgs": "nixpkgs_2"
202
+ },
203
+ "locked": {
204
+ "lastModified": 1762427963,
205
+ "narHash": "sha256-CkPlAbIQ87wmjy5qHibfzk4DmMGBNqFer+lLfXjpP5M=",
206
+ "owner": "pyproject-nix",
207
+ "repo": "pyproject.nix",
208
+ "rev": "4540ea004e04fcd12dd2738d51383d10f956f7b9",
209
+ "type": "github"
210
+ },
211
+ "original": {
212
+ "owner": "pyproject-nix",
213
+ "repo": "pyproject.nix",
214
+ "type": "github"
215
+ }
216
+ },
217
+ "pyproject-nix_3": {
218
+ "inputs": {
219
+ "nixpkgs": [
220
+ "observes_flake_builder",
221
+ "uv2nix",
222
+ "nixpkgs"
223
+ ]
224
+ },
225
+ "locked": {
226
+ "lastModified": 1760402624,
227
+ "narHash": "sha256-jF6UKLs2uGc2rtved8Vrt58oTWjTQoAssuYs/0578Z4=",
228
+ "owner": "pyproject-nix",
229
+ "repo": "pyproject.nix",
230
+ "rev": "84c4ea102127c77058ea1ed7be7300261fafc7d2",
231
+ "type": "github"
232
+ },
233
+ "original": {
234
+ "owner": "pyproject-nix",
235
+ "repo": "pyproject.nix",
236
+ "type": "github"
237
+ }
238
+ },
239
+ "pythonix_flake": {
240
+ "inputs": {
241
+ "nixpkgs_flake": "nixpkgs_flake_2"
242
+ },
243
+ "locked": {
244
+ "dir": "observes/common/pythonix_mirror",
245
+ "lastModified": 1767370831,
246
+ "narHash": "sha256-VR86TSrJsNHQq31Ksga+1dvsrkv9u1pKa0MKuKYeIAc=",
247
+ "ref": "refs/heads/trunk",
248
+ "rev": "0678f8ff3bfe02cfe23bc819bfa739c53bd6e4b6",
249
+ "shallow": true,
250
+ "type": "git",
251
+ "url": "ssh://git@gitlab.com/fluidattacks/universe"
252
+ },
253
+ "original": {
254
+ "dir": "observes/common/pythonix_mirror",
255
+ "rev": "0678f8ff3bfe02cfe23bc819bfa739c53bd6e4b6",
256
+ "shallow": true,
257
+ "type": "git",
258
+ "url": "ssh://git@gitlab.com/fluidattacks/universe"
259
+ }
260
+ },
261
+ "root": {
262
+ "inputs": {
263
+ "observes_flake_builder": "observes_flake_builder"
264
+ }
265
+ },
266
+ "shell-helpers": {
267
+ "inputs": {
268
+ "flake-parts": "flake-parts",
269
+ "nixpkgs": [
270
+ "observes_flake_builder",
271
+ "nixpkgs_flake"
272
+ ]
273
+ },
274
+ "locked": {
275
+ "dir": "common/utils/shell-helpers",
276
+ "lastModified": 1762806066,
277
+ "narHash": "sha256-Wz99Fl7SpPU1NkTHJ36XOo6DjOEAMXCw3ThRABOS2Hs=",
278
+ "ref": "refs/heads/trunk",
279
+ "rev": "d73cfdc7ae9e7f547e22a4481d4c2ccce38b26a8",
280
+ "shallow": true,
281
+ "type": "git",
282
+ "url": "ssh://git@gitlab.com/fluidattacks/universe"
283
+ },
284
+ "original": {
285
+ "dir": "common/utils/shell-helpers",
286
+ "rev": "d73cfdc7ae9e7f547e22a4481d4c2ccce38b26a8",
287
+ "shallow": true,
288
+ "type": "git",
289
+ "url": "ssh://git@gitlab.com/fluidattacks/universe"
290
+ }
291
+ },
292
+ "uv2nix": {
293
+ "inputs": {
294
+ "nixpkgs": [
295
+ "observes_flake_builder",
296
+ "pyproject-build-systems",
297
+ "nixpkgs"
298
+ ],
299
+ "pyproject-nix": [
300
+ "observes_flake_builder",
301
+ "pyproject-build-systems",
302
+ "pyproject-nix"
303
+ ]
304
+ },
305
+ "locked": {
306
+ "lastModified": 1758933732,
307
+ "narHash": "sha256-HAmm1GBS1myZCFuog0DC2ZLaynvZtiUI2Crmo+cdQI0=",
308
+ "owner": "pyproject-nix",
309
+ "repo": "uv2nix",
310
+ "rev": "273ce18f913d8559e0d04f820d724308966d7c4d",
311
+ "type": "github"
312
+ },
313
+ "original": {
314
+ "owner": "pyproject-nix",
315
+ "repo": "uv2nix",
316
+ "type": "github"
317
+ }
318
+ },
319
+ "uv2nix_2": {
320
+ "inputs": {
321
+ "nixpkgs": "nixpkgs_3",
322
+ "pyproject-nix": "pyproject-nix_3"
323
+ },
324
+ "locked": {
325
+ "lastModified": 1761872265,
326
+ "narHash": "sha256-i25GRgp2vUOebY70L3NTAgkd+Pr1hnn5xM3qHxH0ONU=",
327
+ "owner": "pyproject-nix",
328
+ "repo": "uv2nix",
329
+ "rev": "74dfb62871be152ad3673b143b0cc56105a4f3c5",
330
+ "type": "github"
331
+ },
332
+ "original": {
333
+ "owner": "pyproject-nix",
334
+ "repo": "uv2nix",
335
+ "type": "github"
336
+ }
337
+ }
338
+ },
339
+ "root": "root",
340
+ "version": 7
341
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ description = "Utils for sending aws batch jobs";
3
+
4
+ inputs = {
5
+ observes_flake_builder = {
6
+ url = "git+ssh://git@gitlab.com/fluidattacks/universe?shallow=1&rev=3fa54e41d48bd54a59a76f3b0495998663758538&dir=observes/common/std_flake_2";
7
+ };
8
+ };
9
+
10
+ outputs =
11
+ { self, ... }@inputs:
12
+ let
13
+ build_args =
14
+ {
15
+ system,
16
+ python_version,
17
+ nixpkgs,
18
+ builders,
19
+ scripts,
20
+ }:
21
+ import ./build {
22
+ inherit nixpkgs builders scripts;
23
+ src = import ./build/filter.nix nixpkgs.nix-filter self;
24
+ };
25
+ in
26
+ {
27
+ packages = inputs.observes_flake_builder.outputs.build build_args;
28
+ };
29
+ }
@@ -0,0 +1,9 @@
1
+ from ._logger import (
2
+ setup_logger,
3
+ )
4
+ from fa_purity import (
5
+ Unsafe,
6
+ )
7
+
8
+ __version__ = "0.1.0"
9
+ Unsafe.compute(setup_logger(__name__))
@@ -0,0 +1,171 @@
1
+ import dataclasses
2
+
3
+ from fluidattacks_batch_client.decode import JobDefDecoder
4
+ from fluidattacks_batch_client.sender import new_sender
5
+ from .api import (
6
+ new_client,
7
+ )
8
+ from .core import (
9
+ AllowDuplicates,
10
+ JobPipeline,
11
+ JobRequest,
12
+ JobName,
13
+ )
14
+ import click
15
+ from fa_purity import (
16
+ Bool,
17
+ Cmd,
18
+ FrozenList,
19
+ NewFrozenList,
20
+ PureIterFactory,
21
+ PureIterTransform,
22
+ ResultE,
23
+ UnitType,
24
+ Unsafe,
25
+ unit,
26
+ )
27
+ from fa_purity.json import (
28
+ JsonObj,
29
+ JsonValueFactory,
30
+ UnfoldedFactory,
31
+ Unfolder,
32
+ )
33
+ from typing import (
34
+ IO,
35
+ Callable,
36
+ NoReturn,
37
+ TypeVar,
38
+ )
39
+ import logging
40
+ from . import _utils
41
+
42
+ LOG = logging.getLogger(__name__)
43
+
44
+ _T = TypeVar("_T")
45
+
46
+
47
+ def _read_file(file_path: str, transform: Callable[[IO[str]], _T]) -> Cmd[_T]:
48
+ def _action() -> _T:
49
+ with open(file_path, "r", encoding="utf-8") as file:
50
+ return transform(file)
51
+
52
+ return Cmd.wrap_impure(_action)
53
+
54
+
55
+ def _decode_json(file_path: str) -> Cmd[ResultE[JsonObj]]:
56
+ return _read_file(file_path, UnfoldedFactory.load)
57
+
58
+
59
+ def _decode_json_list(file_path: str) -> Cmd[ResultE[FrozenList[JsonObj]]]:
60
+ return _read_file(
61
+ file_path,
62
+ lambda file: JsonValueFactory.load(file).bind(
63
+ lambda v: Unfolder.to_list_of(v, Unfolder.to_json)
64
+ ),
65
+ )
66
+
67
+
68
+ @click.command()
69
+ @click.option("--job", required=True, help="json encoded str defining a JobRequest")
70
+ @click.option("--allow-duplicates", is_flag=True)
71
+ @click.option("--args-in-name", is_flag=True)
72
+ @click.option("--dry-run", is_flag=True)
73
+ @click.argument("args", nargs=-1) # additional args to append into the job command
74
+ def submit_job(
75
+ job: str,
76
+ allow_duplicates: bool,
77
+ args_in_name: bool,
78
+ dry_run: bool,
79
+ args: FrozenList[str],
80
+ ) -> NoReturn:
81
+ def _execute(job: JobRequest) -> Cmd[None]:
82
+ name = Bool.from_primitive(len(args) > 0 and args_in_name).map(
83
+ lambda _: JobName.normalize(job.name.raw + "-" + "-".join(args)),
84
+ lambda _: job.name,
85
+ )
86
+ overriden_job = dataclasses.replace(job, name=name)
87
+ if dry_run:
88
+ return Cmd.wrap_impure(
89
+ lambda: LOG.info(
90
+ "[dry-run] the following batch job will be sent: %s", overriden_job
91
+ )
92
+ )
93
+ return (
94
+ new_client()
95
+ .map(new_sender)
96
+ .bind(
97
+ lambda s: s.send_single_job(
98
+ overriden_job, AllowDuplicates(allow_duplicates)
99
+ ).map(lambda _: None)
100
+ )
101
+ )
102
+
103
+ _decoder = _utils.get_environment.map(JobDefDecoder)
104
+ cmd: Cmd[None] = _decoder.bind(
105
+ lambda decoder: _decode_json(job)
106
+ .map(lambda r: r.bind(decoder.decode_job))
107
+ .map(lambda r: r.alt(Unsafe.raise_exception).to_union())
108
+ .bind(_execute)
109
+ )
110
+ cmd.compute()
111
+
112
+
113
+ @click.command()
114
+ @click.option(
115
+ "--pipeline", required=True, help="json encoded str defining a JobRequest"
116
+ )
117
+ @click.option("--dry-run", is_flag=True)
118
+ def submit_pipeline(
119
+ pipeline: str,
120
+ dry_run: bool,
121
+ ) -> NoReturn:
122
+ def _execute(job_pipeline: JobPipeline) -> Cmd[UnitType]:
123
+ if dry_run:
124
+ msg = Cmd.wrap_impure(
125
+ lambda: LOG.info(
126
+ "[dry-run] A batch pipeline will be sent",
127
+ )
128
+ )
129
+
130
+ msgs = NewFrozenList(tuple(enumerate(job_pipeline.jobs, start=1))).map(
131
+ lambda j: Cmd.wrap_impure(
132
+ lambda: LOG.info(
133
+ "[dry-run] [pipeline-job-#%s] this job will be sent: %s",
134
+ j[0],
135
+ j[1],
136
+ )
137
+ )
138
+ )
139
+ jobs_msgs = (
140
+ PureIterFactory.from_list(msgs.items)
141
+ .transform(PureIterTransform.consume)
142
+ .map(lambda _: unit)
143
+ )
144
+ return msg + jobs_msgs
145
+ return (
146
+ new_client()
147
+ .map(new_sender)
148
+ .bind(
149
+ lambda s: s.send_pipeline(
150
+ PureIterFactory.from_list(job_pipeline.jobs.items)
151
+ )
152
+ )
153
+ )
154
+
155
+ _decoder = _utils.get_environment.map(JobDefDecoder)
156
+ cmd: Cmd[UnitType] = _decoder.bind(
157
+ lambda decoder: _decode_json_list(pipeline)
158
+ .map(lambda r: r.map(NewFrozenList).bind(decoder.decode_pipeline))
159
+ .map(lambda r: r.alt(Unsafe.raise_exception).to_union())
160
+ .bind(_execute)
161
+ )
162
+ cmd.compute()
163
+
164
+
165
+ @click.group()
166
+ def main() -> None:
167
+ pass
168
+
169
+
170
+ main.add_command(submit_job)
171
+ main.add_command(submit_pipeline)
@@ -0,0 +1,17 @@
1
+ from fa_purity import (
2
+ Cmd,
3
+ )
4
+ import logging
5
+ import sys
6
+
7
+
8
+ def setup_logger(name: str) -> Cmd[None]:
9
+ def _action() -> None:
10
+ handler = logging.StreamHandler(sys.stderr)
11
+ formatter = logging.Formatter("[%(levelname)s] %(message)s")
12
+ handler.setFormatter(formatter)
13
+ log = logging.getLogger(name)
14
+ log.addHandler(handler)
15
+ log.setLevel(logging.INFO)
16
+
17
+ return Cmd.wrap_impure(_action)