pipen-cli-gbatch 0.0.2__py3-none-any.whl → 0.0.3__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 +25 -11
- pipen_cli_gbatch/daemon_args.toml +6 -5
- {pipen_cli_gbatch-0.0.2.dist-info → pipen_cli_gbatch-0.0.3.dist-info}/METADATA +3 -1
- pipen_cli_gbatch-0.0.3.dist-info/RECORD +6 -0
- pipen_cli_gbatch-0.0.2.dist-info/RECORD +0 -6
- {pipen_cli_gbatch-0.0.2.dist-info → pipen_cli_gbatch-0.0.3.dist-info}/WHEEL +0 -0
- {pipen_cli_gbatch-0.0.2.dist-info → pipen_cli_gbatch-0.0.3.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.0.
|
|
82
|
+
__version__ = "0.0.3"
|
|
83
83
|
__all__ = ("CliGbatchPlugin", "CliGbatchDaemon")
|
|
84
84
|
|
|
85
85
|
|
|
@@ -117,6 +117,11 @@ class CliGbatchDaemon:
|
|
|
117
117
|
|
|
118
118
|
self.config.prescript = self.config.get("prescript", None) or ""
|
|
119
119
|
self.config.postscript = self.config.get("postscript", None) or ""
|
|
120
|
+
if "labels" in self.config and isinstance(self.config.labels, list):
|
|
121
|
+
self.config.labels = {
|
|
122
|
+
key: val
|
|
123
|
+
for key, val in (item.split("=", 1) for item in self.config.labels)
|
|
124
|
+
}
|
|
120
125
|
self.command = command
|
|
121
126
|
|
|
122
127
|
def _get_arg_from_command(self, arg: str) -> str | None:
|
|
@@ -183,7 +188,7 @@ class CliGbatchDaemon:
|
|
|
183
188
|
"""
|
|
184
189
|
mount = self.config.get("mount", [])
|
|
185
190
|
# mount the workdir
|
|
186
|
-
mount.append(f
|
|
191
|
+
mount.append(f"{source}:{target}")
|
|
187
192
|
|
|
188
193
|
self.config["mount"] = mount
|
|
189
194
|
|
|
@@ -197,7 +202,7 @@ class CliGbatchDaemon:
|
|
|
197
202
|
SystemExit: If workdir is not a valid Google Storage bucket path.
|
|
198
203
|
"""
|
|
199
204
|
command_workdir = self._get_arg_from_command("workdir")
|
|
200
|
-
workdir = self.config.get("workdir", command_workdir
|
|
205
|
+
workdir = self.config.get("workdir", None) or command_workdir
|
|
201
206
|
|
|
202
207
|
if not workdir or not isinstance(AnyPath(workdir), GSPath):
|
|
203
208
|
print(
|
|
@@ -493,7 +498,7 @@ class CliGbatchDaemon:
|
|
|
493
498
|
)
|
|
494
499
|
sys.exit(1)
|
|
495
500
|
|
|
496
|
-
if
|
|
501
|
+
if "name" not in self.config:
|
|
497
502
|
self.config["name"] = "PipenCliGbatchDaemon"
|
|
498
503
|
|
|
499
504
|
async def run(self): # pragma: no cover
|
|
@@ -553,6 +558,17 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
553
558
|
logger.error(f"/STDERR {self.stderr_populator.residue}")
|
|
554
559
|
self.stderr_populator.residue = ""
|
|
555
560
|
|
|
561
|
+
@plugin.impl
|
|
562
|
+
async def on_job_init(self, scheduler, job):
|
|
563
|
+
"""Handle job initialization event.
|
|
564
|
+
|
|
565
|
+
Args:
|
|
566
|
+
scheduler: The scheduler instance.
|
|
567
|
+
job: The job being initialized.
|
|
568
|
+
"""
|
|
569
|
+
self.stdout_populator.logfile = scheduler.workdir.joinpath("0", "job.stdout")
|
|
570
|
+
self.stderr_populator.logfile = scheduler.workdir.joinpath("0", "job.stderr")
|
|
571
|
+
|
|
556
572
|
@plugin.impl
|
|
557
573
|
async def on_job_started(self, scheduler, job):
|
|
558
574
|
"""Handle job start event by setting up log file paths.
|
|
@@ -564,8 +580,6 @@ class XquteCliGbatchPlugin: # pragma: no cover
|
|
|
564
580
|
if not self.log_start:
|
|
565
581
|
return
|
|
566
582
|
|
|
567
|
-
self.stdout_populator.logfile = scheduler.workdir.joinpath("0", "job.stdout")
|
|
568
|
-
self.stderr_populator.logfile = scheduler.workdir.joinpath("0", "job.stderr")
|
|
569
583
|
logger.info("Job is picked up by Google Batch, pulling stdout/stderr...")
|
|
570
584
|
|
|
571
585
|
@plugin.impl
|
|
@@ -693,29 +707,29 @@ class CliGbatchPlugin(CLIPlugin): # pragma: no cover
|
|
|
693
707
|
super().__init__(parser, subparser)
|
|
694
708
|
subparser.epilog = """\033[1;4mExamples\033[0m:
|
|
695
709
|
|
|
696
|
-
\
|
|
710
|
+
\u200b
|
|
697
711
|
# Run a command and wait for it to complete
|
|
698
712
|
> pipen gbatch --workdir gs://my-bucket/workdir -- \\
|
|
699
713
|
python myscript.py --input input.txt --output output.txt
|
|
700
714
|
|
|
701
|
-
\
|
|
715
|
+
\u200b
|
|
702
716
|
# Use named mounts
|
|
703
717
|
> pipen gbatch --workdir gs://my-bucket/workdir --mount INFILE=gs://bucket/path/to/file \\
|
|
704
718
|
--mount OUTDIR=gs://bucket/path/to/outdir -- \\
|
|
705
719
|
bash -c 'cat $INFILE > $OUTDIR/output.txt'
|
|
706
720
|
|
|
707
|
-
\
|
|
721
|
+
\u200b
|
|
708
722
|
# Run a command in a detached mode
|
|
709
723
|
> pipen gbatch --nowait --project $PROJECT --location $LOCATION \\
|
|
710
724
|
--workdir gs://my-bucket/workdir -- \\
|
|
711
725
|
python myscript.py --input input.txt --output output.txt
|
|
712
726
|
|
|
713
|
-
\
|
|
727
|
+
\u200b
|
|
714
728
|
# If you have a profile defined in ~/.pipen.toml or ./.pipen.toml
|
|
715
729
|
> pipen gbatch --profile myprofile -- \\
|
|
716
730
|
python myscript.py --input input.txt --output output.txt
|
|
717
731
|
|
|
718
|
-
\
|
|
732
|
+
\u200b
|
|
719
733
|
# View the logs of a previously run command
|
|
720
734
|
> pipen gbatch --view-logs all --name my-daemon-name \\
|
|
721
735
|
--workdir gs://my-bucket/workdir
|
|
@@ -186,20 +186,21 @@ and positive values mean to run after the main command."""
|
|
|
186
186
|
[[groups.arguments]]
|
|
187
187
|
flags = ["--allocationPolicy"]
|
|
188
188
|
type = "json"
|
|
189
|
-
default =
|
|
189
|
+
default = {}
|
|
190
190
|
help = "The JSON string of extra settings of allocationPolicy add to the job.json. Refer to https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#AllocationPolicy for details."
|
|
191
191
|
|
|
192
192
|
[[groups.arguments]]
|
|
193
193
|
flags = ["--taskGroups"]
|
|
194
194
|
type = "json"
|
|
195
|
-
default =
|
|
195
|
+
default = []
|
|
196
196
|
help = "The JSON string of extra settings of taskGroups add to the job.json. Refer to https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#TaskGroup for details."
|
|
197
197
|
|
|
198
198
|
[[groups.arguments]]
|
|
199
199
|
flags = ["--labels"]
|
|
200
|
-
type = "json"
|
|
201
|
-
default =
|
|
202
|
-
|
|
200
|
+
# type = "json"
|
|
201
|
+
default = []
|
|
202
|
+
action = "clear_append"
|
|
203
|
+
help = "The strings of labels to add to the job (key=value). Refer to https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#Job.FIELDS.labels for details."
|
|
203
204
|
|
|
204
205
|
[[groups.arguments]]
|
|
205
206
|
flags = ["--gcloud"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pipen-cli-gbatch
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: A pipen cli plugin to run command via Google Cloud Batch
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: pwwang
|
|
@@ -16,6 +16,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
16
16
|
Requires-Dist: google-cloud-storage (>=3.0.0,<4.0.0)
|
|
17
17
|
Requires-Dist: pipen (>=0.17.19,<0.18.0)
|
|
18
18
|
Requires-Dist: pipen-poplog (>=0.3.6,<0.4.0)
|
|
19
|
+
Project-URL: Homepage, https://github.com/pwwang/pipen-cli-gbatch
|
|
20
|
+
Project-URL: Repository, https://github.com/pwwang/pipen-cli-gbatch
|
|
19
21
|
Description-Content-Type: text/markdown
|
|
20
22
|
|
|
21
23
|
# pipen-cli-gbatch
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pipen_cli_gbatch/__init__.py,sha256=rpkQ3NA8g4zNnzKaBz3jNZVKNDIIEPRewHK1OCvR9EA,28766
|
|
2
|
+
pipen_cli_gbatch/daemon_args.toml,sha256=PZJ7DHIvGsfVxPwDT0rhdHQb6WxnA10ebXnQOfv4faM,6879
|
|
3
|
+
pipen_cli_gbatch-0.0.3.dist-info/METADATA,sha256=jzaT7B6fAHU8xkUfINHPBOFezxnXUPm0GhiYLEft4Dg,11250
|
|
4
|
+
pipen_cli_gbatch-0.0.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
5
|
+
pipen_cli_gbatch-0.0.3.dist-info/entry_points.txt,sha256=Z9NLeCpRo-rb8wss5mB5TBcG-_RbdlPA49b8Ma5pvQA,57
|
|
6
|
+
pipen_cli_gbatch-0.0.3.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
pipen_cli_gbatch/__init__.py,sha256=cTX5Sdt-42el8s4mW2daAUQcCieP_2kOiJpzR0zzags,28294
|
|
2
|
-
pipen_cli_gbatch/daemon_args.toml,sha256=Q_fbj1Eesj02A74RDteSCXGE8s9iaRF9pAzYZOyF8ek,6851
|
|
3
|
-
pipen_cli_gbatch-0.0.2.dist-info/METADATA,sha256=y7v2ah3bPm8RzFeSqvA78jC7GUU8g4SRPPzSOgMp9vk,11116
|
|
4
|
-
pipen_cli_gbatch-0.0.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
5
|
-
pipen_cli_gbatch-0.0.2.dist-info/entry_points.txt,sha256=Z9NLeCpRo-rb8wss5mB5TBcG-_RbdlPA49b8Ma5pvQA,57
|
|
6
|
-
pipen_cli_gbatch-0.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|