pipen-cli-gbatch 0.0.4__py3-none-any.whl → 0.0.6__py3-none-any.whl
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.
Potentially problematic release.
This version of pipen-cli-gbatch might be problematic. Click here for more details.
- pipen_cli_gbatch/__init__.py +47 -17
- pipen_cli_gbatch/daemon_args.toml +10 -0
- {pipen_cli_gbatch-0.0.4.dist-info → pipen_cli_gbatch-0.0.6.dist-info}/METADATA +1 -1
- pipen_cli_gbatch-0.0.6.dist-info/RECORD +6 -0
- pipen_cli_gbatch-0.0.4.dist-info/RECORD +0 -6
- {pipen_cli_gbatch-0.0.4.dist-info → pipen_cli_gbatch-0.0.6.dist-info}/WHEEL +0 -0
- {pipen_cli_gbatch-0.0.4.dist-info → pipen_cli_gbatch-0.0.6.dist-info}/entry_points.txt +0 -0
pipen_cli_gbatch/__init__.py
CHANGED
|
@@ -79,8 +79,9 @@ from pipen.cli import CLIPlugin
|
|
|
79
79
|
from pipen.scheduler import GbatchScheduler
|
|
80
80
|
from pipen_poplog import LogsPopulator
|
|
81
81
|
|
|
82
|
-
__version__ = "0.0.
|
|
82
|
+
__version__ = "0.0.6"
|
|
83
83
|
__all__ = ("CliGbatchPlugin", "CliGbatchDaemon")
|
|
84
|
+
MOUNTED_CWD = "/mnt/disks/.cwd"
|
|
84
85
|
|
|
85
86
|
|
|
86
87
|
class CliGbatchDaemon:
|
|
@@ -115,6 +116,17 @@ class CliGbatchDaemon:
|
|
|
115
116
|
else:
|
|
116
117
|
self.config = Diot(config)
|
|
117
118
|
|
|
119
|
+
self.mount_as_cwd = self.config.pop("mount_as_cwd", None)
|
|
120
|
+
if self.mount_as_cwd:
|
|
121
|
+
if self.config.cwd:
|
|
122
|
+
print(
|
|
123
|
+
"\033[1;4mError\033[0m: --mount-as-cwd cannot be used with "
|
|
124
|
+
"--cwd at the same time.\n"
|
|
125
|
+
)
|
|
126
|
+
sys.exit(1)
|
|
127
|
+
self.config.cwd = MOUNTED_CWD
|
|
128
|
+
self._add_mount(self.mount_as_cwd, MOUNTED_CWD)
|
|
129
|
+
|
|
118
130
|
self.config.prescript = self.config.get("prescript", None) or ""
|
|
119
131
|
self.config.postscript = self.config.get("postscript", None) or ""
|
|
120
132
|
if "labels" in self.config and isinstance(self.config.labels, list):
|
|
@@ -201,6 +213,11 @@ class CliGbatchDaemon:
|
|
|
201
213
|
Raises:
|
|
202
214
|
SystemExit: If workdir is not a valid Google Storage bucket path.
|
|
203
215
|
"""
|
|
216
|
+
command_name = self._get_arg_from_command("name") or self.config["name"]
|
|
217
|
+
from_mount_as_cwd = self.mount_as_cwd and not self.config.workdir
|
|
218
|
+
if from_mount_as_cwd:
|
|
219
|
+
self.config.workdir = f"{self.mount_as_cwd}/.pipen/{command_name}"
|
|
220
|
+
|
|
204
221
|
command_workdir = self._get_arg_from_command("workdir")
|
|
205
222
|
workdir = self.config.get("workdir", None) or command_workdir
|
|
206
223
|
|
|
@@ -212,11 +229,14 @@ class CliGbatchDaemon:
|
|
|
212
229
|
sys.exit(1)
|
|
213
230
|
|
|
214
231
|
self.config["workdir"] = workdir
|
|
215
|
-
#
|
|
216
|
-
|
|
232
|
+
if from_mount_as_cwd: # already mounted
|
|
233
|
+
self._replace_arg_in_command("workdir", f"{MOUNTED_CWD}/.pipen")
|
|
234
|
+
else:
|
|
235
|
+
# If command workdir is different from config workdir, we need to mount it
|
|
236
|
+
self._add_mount(workdir, GbatchScheduler.MOUNTED_METADIR)
|
|
217
237
|
|
|
218
|
-
|
|
219
|
-
|
|
238
|
+
# replace --workdir value with the mounted workdir in the command
|
|
239
|
+
self._replace_arg_in_command("workdir", GbatchScheduler.MOUNTED_METADIR)
|
|
220
240
|
|
|
221
241
|
def _handle_outdir(self):
|
|
222
242
|
"""Handle output directory configuration and mounting.
|
|
@@ -229,6 +249,12 @@ class CliGbatchDaemon:
|
|
|
229
249
|
if command_outdir:
|
|
230
250
|
self._add_mount(command_outdir, GbatchScheduler.MOUNTED_OUTDIR)
|
|
231
251
|
self._replace_arg_in_command("outdir", GbatchScheduler.MOUNTED_OUTDIR)
|
|
252
|
+
elif self.mount_as_cwd:
|
|
253
|
+
command_name = self._get_arg_from_command("name") or self.config.name
|
|
254
|
+
self._replace_arg_in_command(
|
|
255
|
+
"outdir",
|
|
256
|
+
f"{MOUNTED_CWD}/{command_name}-output",
|
|
257
|
+
)
|
|
232
258
|
|
|
233
259
|
def _infer_name(self):
|
|
234
260
|
"""Infer the daemon name from configuration or command arguments.
|
|
@@ -303,6 +329,7 @@ class CliGbatchDaemon:
|
|
|
303
329
|
"version",
|
|
304
330
|
"loglevel",
|
|
305
331
|
"mounts",
|
|
332
|
+
"mount_as_cwd",
|
|
306
333
|
"plain",
|
|
307
334
|
)
|
|
308
335
|
},
|
|
@@ -333,6 +360,7 @@ class CliGbatchDaemon:
|
|
|
333
360
|
"version",
|
|
334
361
|
"loglevel",
|
|
335
362
|
"mounts",
|
|
363
|
+
"mount_as_cwd",
|
|
336
364
|
"plain",
|
|
337
365
|
):
|
|
338
366
|
continue
|
|
@@ -483,9 +511,9 @@ class CliGbatchDaemon:
|
|
|
483
511
|
logger.setLevel(self.config.loglevel.upper())
|
|
484
512
|
|
|
485
513
|
if not self.config.plain:
|
|
514
|
+
self._infer_name()
|
|
486
515
|
self._handle_workdir()
|
|
487
516
|
self._handle_outdir()
|
|
488
|
-
self._infer_name()
|
|
489
517
|
self._infer_jobname_prefix()
|
|
490
518
|
else:
|
|
491
519
|
if not self.config.workdir or not isinstance(
|
|
@@ -551,10 +579,10 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
551
579
|
|
|
552
580
|
def _clear_residues(self):
|
|
553
581
|
"""Clear any remaining log residues and display them."""
|
|
554
|
-
if self.stdout_populator.residue:
|
|
582
|
+
if self.stdout_populator and self.stdout_populator.residue:
|
|
555
583
|
logger.info(f"/STDOUT {self.stdout_populator.residue}")
|
|
556
584
|
self.stdout_populator.residue = ""
|
|
557
|
-
if self.stderr_populator.residue:
|
|
585
|
+
if self.stderr_populator and self.stderr_populator.residue:
|
|
558
586
|
logger.error(f"/STDERR {self.stderr_populator.residue}")
|
|
559
587
|
self.stderr_populator.residue = ""
|
|
560
588
|
|
|
@@ -595,15 +623,17 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
595
623
|
# Make it less frequent
|
|
596
624
|
return
|
|
597
625
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
self.stderr_populator
|
|
605
|
-
|
|
606
|
-
|
|
626
|
+
if self.stderr_populator:
|
|
627
|
+
stdout_lines = self.stdout_populator.populate()
|
|
628
|
+
self.stdout_populator.increment_counter(len(stdout_lines))
|
|
629
|
+
for line in stdout_lines:
|
|
630
|
+
logger.info(f"/STDOUT {line}")
|
|
631
|
+
|
|
632
|
+
if self.stderr_populator:
|
|
633
|
+
stderr_lines = self.stderr_populator.populate()
|
|
634
|
+
self.stderr_populator.increment_counter(len(stderr_lines))
|
|
635
|
+
for line in stderr_lines:
|
|
636
|
+
logger.error(f"/STDERR {line}")
|
|
607
637
|
|
|
608
638
|
@plugin.impl
|
|
609
639
|
async def on_job_killed(self, scheduler, job):
|
|
@@ -128,6 +128,16 @@ You can also mount a file like `INFILE=gs://my-bucket/inputs/file.txt`. The pare
|
|
|
128
128
|
and the file will be available at `/mnt/disks/INFILE/inputs/file.txt` in the VM. `$INFILE` can also be used in the command/script to refer to the mounted path.
|
|
129
129
|
"""
|
|
130
130
|
|
|
131
|
+
[[groups.arguments]]
|
|
132
|
+
flags = ["--mount-as-cwd"]
|
|
133
|
+
type = "str"
|
|
134
|
+
help = """The directory to mount as the current working directory of the command.
|
|
135
|
+
This is a shortcut for `--mount <cloudpath>:/mnt/disks/.cwd --cwd /mnt/disks/.cwd`.
|
|
136
|
+
The <cloudpath> must be a Google Storage Bucket path (gs://...). When this option is used,
|
|
137
|
+
and `--workdir` is not provided, the workdir will be set to `<cloudpath>/.pipen/<command_name>`,
|
|
138
|
+
where <command_name> is the name of the command (or the value of `--name` if provided).
|
|
139
|
+
"""
|
|
140
|
+
|
|
131
141
|
[[groups.arguments]]
|
|
132
142
|
flags = ["--service-account"]
|
|
133
143
|
type = "str"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pipen_cli_gbatch/__init__.py,sha256=5ChKkEGzq1S2irrwHpNts2oqezfB1zKs5IA2i3YJd-c,30862
|
|
2
|
+
pipen_cli_gbatch/daemon_args.toml,sha256=XrCDwTaJ7xPgGLtZev4qikjrZWqixdE8tqSsFnIvmjc,7381
|
|
3
|
+
pipen_cli_gbatch-0.0.6.dist-info/METADATA,sha256=ZvlRbQNOG6k2EIe2UeE4f469VP8AZM_IcLDlkuw91wg,11301
|
|
4
|
+
pipen_cli_gbatch-0.0.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
5
|
+
pipen_cli_gbatch-0.0.6.dist-info/entry_points.txt,sha256=Z9NLeCpRo-rb8wss5mB5TBcG-_RbdlPA49b8Ma5pvQA,57
|
|
6
|
+
pipen_cli_gbatch-0.0.6.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
pipen_cli_gbatch/__init__.py,sha256=x5R1wU-TyXS_Z1EqJ1jWhFn66sKLt_fg8eyXtz9k7rg,29508
|
|
2
|
-
pipen_cli_gbatch/daemon_args.toml,sha256=YzqLumFjIY8mRMzRt3M5D1fEjK93QvQJ0XynDnimPIo,6873
|
|
3
|
-
pipen_cli_gbatch-0.0.4.dist-info/METADATA,sha256=5i6JjljULy5Km96zlHt0dcI97Wleq73yzYpakX5j8Zw,11301
|
|
4
|
-
pipen_cli_gbatch-0.0.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
5
|
-
pipen_cli_gbatch-0.0.4.dist-info/entry_points.txt,sha256=Z9NLeCpRo-rb8wss5mB5TBcG-_RbdlPA49b8Ma5pvQA,57
|
|
6
|
-
pipen_cli_gbatch-0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|