pipen-cli-gbatch 0.0.7__py3-none-any.whl → 0.1.1__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 +59 -27
- {pipen_cli_gbatch-0.0.7.dist-info → pipen_cli_gbatch-0.1.1.dist-info}/METADATA +1 -1
- pipen_cli_gbatch-0.1.1.dist-info/RECORD +6 -0
- pipen_cli_gbatch-0.0.7.dist-info/RECORD +0 -6
- {pipen_cli_gbatch-0.0.7.dist-info → pipen_cli_gbatch-0.1.1.dist-info}/WHEEL +0 -0
- {pipen_cli_gbatch-0.0.7.dist-info → pipen_cli_gbatch-0.1.1.dist-info}/entry_points.txt +0 -0
pipen_cli_gbatch/__init__.py
CHANGED
|
@@ -79,7 +79,7 @@ from pipen.cli import CLIPlugin
|
|
|
79
79
|
from pipen.scheduler import GbatchScheduler
|
|
80
80
|
from pipen_poplog import LogsPopulator
|
|
81
81
|
|
|
82
|
-
__version__ = "0.
|
|
82
|
+
__version__ = "0.1.1"
|
|
83
83
|
__all__ = ("CliGbatchPlugin", "CliGbatchDaemon")
|
|
84
84
|
MOUNTED_CWD = "/mnt/disks/.cwd"
|
|
85
85
|
|
|
@@ -135,6 +135,7 @@ class CliGbatchDaemon:
|
|
|
135
135
|
for key, val in (item.split("=", 1) for item in self.config.labels)
|
|
136
136
|
}
|
|
137
137
|
self.command = command
|
|
138
|
+
self._command_workdir = None
|
|
138
139
|
|
|
139
140
|
def _get_arg_from_command(self, arg: str) -> str | None:
|
|
140
141
|
"""Get the value of the given argument from the command line.
|
|
@@ -218,8 +219,10 @@ class CliGbatchDaemon:
|
|
|
218
219
|
if from_mount_as_cwd:
|
|
219
220
|
self.config.workdir = f"{self.mount_as_cwd}/.pipen/{command_name}"
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
# self._command_workdir to save the original command workdir
|
|
223
|
+
self._command_workdir = workdir = (
|
|
224
|
+
self.config.get("workdir", None) or self._get_arg_from_command("workdir")
|
|
225
|
+
)
|
|
223
226
|
|
|
224
227
|
if not workdir or not isinstance(AnyPath(workdir), GSPath):
|
|
225
228
|
print(
|
|
@@ -312,7 +315,13 @@ class CliGbatchDaemon:
|
|
|
312
315
|
and not self.config.view_logs
|
|
313
316
|
and "logging" not in plugin.get_all_plugin_names()
|
|
314
317
|
):
|
|
315
|
-
|
|
318
|
+
if self.config.plain:
|
|
319
|
+
# use the stdout file from daemon
|
|
320
|
+
stdout_file = None
|
|
321
|
+
else:
|
|
322
|
+
stdout_file = AnyPath(f"{self._command_workdir}/run-latest.log")
|
|
323
|
+
|
|
324
|
+
plugins.append(XquteCliGbatchPlugin(stdout_file=stdout_file))
|
|
316
325
|
|
|
317
326
|
return Xqute(
|
|
318
327
|
"gbatch",
|
|
@@ -540,7 +549,6 @@ class CliGbatchDaemon:
|
|
|
540
549
|
)
|
|
541
550
|
sys.exit(1)
|
|
542
551
|
|
|
543
|
-
|
|
544
552
|
async def run(self): # pragma: no cover
|
|
545
553
|
"""Execute the daemon pipeline based on configuration.
|
|
546
554
|
|
|
@@ -572,12 +580,15 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
572
580
|
|
|
573
581
|
Attributes:
|
|
574
582
|
name (str): The plugin name.
|
|
575
|
-
log_start (bool): Whether to start logging when job starts.
|
|
576
583
|
stdout_populator (LogsPopulator): Handles stdout log population.
|
|
577
584
|
stderr_populator (LogsPopulator): Handles stderr log population.
|
|
578
585
|
"""
|
|
579
586
|
|
|
580
|
-
def __init__(
|
|
587
|
+
def __init__(
|
|
588
|
+
self,
|
|
589
|
+
name: str = "logging",
|
|
590
|
+
stdout_file: str | Path | GSPath | None = None,
|
|
591
|
+
):
|
|
581
592
|
"""Initialize the logging plugin.
|
|
582
593
|
|
|
583
594
|
Args:
|
|
@@ -585,7 +596,7 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
585
596
|
log_start: Whether to start logging when job starts.
|
|
586
597
|
"""
|
|
587
598
|
self.name = name
|
|
588
|
-
self.
|
|
599
|
+
self.stdout_file = stdout_file
|
|
589
600
|
self.stdout_populator = LogsPopulator()
|
|
590
601
|
self.stderr_populator = LogsPopulator()
|
|
591
602
|
|
|
@@ -598,17 +609,6 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
598
609
|
logger.error(f"/STDERR {self.stderr_populator.residue}")
|
|
599
610
|
self.stderr_populator.residue = ""
|
|
600
611
|
|
|
601
|
-
@plugin.impl
|
|
602
|
-
async def on_job_init(self, scheduler, job):
|
|
603
|
-
"""Handle job initialization event.
|
|
604
|
-
|
|
605
|
-
Args:
|
|
606
|
-
scheduler: The scheduler instance.
|
|
607
|
-
job: The job being initialized.
|
|
608
|
-
"""
|
|
609
|
-
self.stdout_populator.logfile = scheduler.workdir.joinpath("0", "job.stdout")
|
|
610
|
-
self.stderr_populator.logfile = scheduler.workdir.joinpath("0", "job.stderr")
|
|
611
|
-
|
|
612
612
|
@plugin.impl
|
|
613
613
|
async def on_job_started(self, scheduler, job):
|
|
614
614
|
"""Handle job start event by setting up log file paths.
|
|
@@ -617,10 +617,46 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
617
617
|
scheduler: The scheduler instance.
|
|
618
618
|
job: The job that started.
|
|
619
619
|
"""
|
|
620
|
-
|
|
621
|
-
|
|
620
|
+
logger.info("Job is picked up by Google Batch, pulling stdout/stderr ...")
|
|
621
|
+
if not self.stdout_file:
|
|
622
|
+
self.stdout_populator.logfile = scheduler.workdir.joinpath(
|
|
623
|
+
"0", "job.stdout"
|
|
624
|
+
)
|
|
625
|
+
elif not self.stdout_file.exists():
|
|
626
|
+
logger.warning(f"Running logs file not found: {self.stdout_file}")
|
|
627
|
+
logger.warning(" Waiting for it to be created ...")
|
|
628
|
+
i = 0
|
|
629
|
+
while not self.stdout_file.exists():
|
|
630
|
+
await asyncio.sleep(3)
|
|
631
|
+
i += 1
|
|
632
|
+
if i >= 20:
|
|
633
|
+
break
|
|
634
|
+
|
|
635
|
+
if not self.stdout_file.exists():
|
|
636
|
+
logger.warning(
|
|
637
|
+
" Still not found, falling back to pull logs from daemon ..."
|
|
638
|
+
)
|
|
639
|
+
logger.warning(
|
|
640
|
+
" Make sure pipen-log2file plugin is enabled for your pipeline."
|
|
641
|
+
)
|
|
642
|
+
self.stdout_populator.logfile = scheduler.workdir.joinpath(
|
|
643
|
+
"0", "job.stdout"
|
|
644
|
+
)
|
|
645
|
+
else:
|
|
646
|
+
logger.info(" Found the running logs, pulling ...")
|
|
647
|
+
self.stdout_populator.logfile = (
|
|
648
|
+
self.stdout_file.resolve()
|
|
649
|
+
if self.stdout_file.is_symlink()
|
|
650
|
+
else self.stdout_file
|
|
651
|
+
)
|
|
652
|
+
else:
|
|
653
|
+
self.stdout_populator.logfile = (
|
|
654
|
+
self.stdout_file.resolve()
|
|
655
|
+
if self.stdout_file.is_symlink()
|
|
656
|
+
else self.stdout_file
|
|
657
|
+
)
|
|
622
658
|
|
|
623
|
-
|
|
659
|
+
self.stderr_populator.logfile = scheduler.workdir.joinpath("0", "job.stderr")
|
|
624
660
|
|
|
625
661
|
@plugin.impl
|
|
626
662
|
async def on_job_polling(self, scheduler, job, counter):
|
|
@@ -821,11 +857,7 @@ class CliGbatchPlugin(CLIPlugin): # pragma: no cover
|
|
|
821
857
|
|
|
822
858
|
# update parsed with the defaults
|
|
823
859
|
for key, val in defaults.items():
|
|
824
|
-
if (
|
|
825
|
-
key == "mount"
|
|
826
|
-
and val
|
|
827
|
-
and getattr(known_parsed, key, None)
|
|
828
|
-
):
|
|
860
|
+
if key == "mount" and val and getattr(known_parsed, key, None):
|
|
829
861
|
if not isinstance(val, (tuple, list)):
|
|
830
862
|
val = [val]
|
|
831
863
|
val = list(val)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pipen_cli_gbatch/__init__.py,sha256=_8YcTVxCzFRfD-mf9bXP4tplcEhMkFFlOuVkla-jFas,32698
|
|
2
|
+
pipen_cli_gbatch/daemon_args.toml,sha256=XrCDwTaJ7xPgGLtZev4qikjrZWqixdE8tqSsFnIvmjc,7381
|
|
3
|
+
pipen_cli_gbatch-0.1.1.dist-info/METADATA,sha256=kvLiPVSXeqLJeNvFuR2TS_o-lQw9uoSjNBfYLcg_MoI,11301
|
|
4
|
+
pipen_cli_gbatch-0.1.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
5
|
+
pipen_cli_gbatch-0.1.1.dist-info/entry_points.txt,sha256=Z9NLeCpRo-rb8wss5mB5TBcG-_RbdlPA49b8Ma5pvQA,57
|
|
6
|
+
pipen_cli_gbatch-0.1.1.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
pipen_cli_gbatch/__init__.py,sha256=xiYBNz3z3Eu8vmFECPFpOt1EE501T_gZx_iPUDajCd4,31309
|
|
2
|
-
pipen_cli_gbatch/daemon_args.toml,sha256=XrCDwTaJ7xPgGLtZev4qikjrZWqixdE8tqSsFnIvmjc,7381
|
|
3
|
-
pipen_cli_gbatch-0.0.7.dist-info/METADATA,sha256=pxmFaIpwMG6GU4wZF_1EBqtWa9l44KI-m1Lhi3TI1Dw,11301
|
|
4
|
-
pipen_cli_gbatch-0.0.7.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
5
|
-
pipen_cli_gbatch-0.0.7.dist-info/entry_points.txt,sha256=Z9NLeCpRo-rb8wss5mB5TBcG-_RbdlPA49b8Ma5pvQA,57
|
|
6
|
-
pipen_cli_gbatch-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|