pipen-cli-gbatch 0.0.3__py3-none-any.whl → 0.0.5__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.

@@ -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.3"
82
+ __version__ = "0.0.5"
83
83
  __all__ = ("CliGbatchPlugin", "CliGbatchDaemon")
84
84
 
85
85
 
@@ -317,7 +317,7 @@ class CliGbatchDaemon:
317
317
 
318
318
  def _show_scheduler_opts(self):
319
319
  """Log the scheduler options for debugging purposes."""
320
- logger.debug("Scheduler Options:")
320
+ logger.info("Scheduler Options:")
321
321
  for key, val in self.config.items():
322
322
  if key in (
323
323
  "workdir",
@@ -337,7 +337,7 @@ class CliGbatchDaemon:
337
337
  ):
338
338
  continue
339
339
 
340
- logger.debug(f"- {key}: {val}")
340
+ logger.info(f"- {key}: {val}")
341
341
 
342
342
  async def _run_wait(self): # pragma: no cover
343
343
  """Run the pipeline and wait for completion.
@@ -498,7 +498,7 @@ class CliGbatchDaemon:
498
498
  )
499
499
  sys.exit(1)
500
500
 
501
- if "name" not in self.config:
501
+ if "name" not in self.config or not self.config.name:
502
502
  self.config["name"] = "PipenCliGbatchDaemon"
503
503
 
504
504
  async def run(self): # pragma: no cover
@@ -551,10 +551,10 @@ class XquteCliGbatchPlugin: # pragma: no cover
551
551
 
552
552
  def _clear_residues(self):
553
553
  """Clear any remaining log residues and display them."""
554
- if self.stdout_populator.residue:
554
+ if self.stdout_populator and self.stdout_populator.residue:
555
555
  logger.info(f"/STDOUT {self.stdout_populator.residue}")
556
556
  self.stdout_populator.residue = ""
557
- if self.stderr_populator.residue:
557
+ if self.stderr_populator and self.stderr_populator.residue:
558
558
  logger.error(f"/STDERR {self.stderr_populator.residue}")
559
559
  self.stderr_populator.residue = ""
560
560
 
@@ -595,15 +595,17 @@ class XquteCliGbatchPlugin: # pragma: no cover
595
595
  # Make it less frequent
596
596
  return
597
597
 
598
- stdout_lines = self.stdout_populator.populate()
599
- self.stdout_populator.increment_counter(len(stdout_lines))
600
- for line in stdout_lines:
601
- logger.info(f"/STDOUT {line}")
598
+ if self.stderr_populator:
599
+ stdout_lines = self.stdout_populator.populate()
600
+ self.stdout_populator.increment_counter(len(stdout_lines))
601
+ for line in stdout_lines:
602
+ logger.info(f"/STDOUT {line}")
602
603
 
603
- stderr_lines = self.stderr_populator.populate()
604
- self.stderr_populator.increment_counter(len(stderr_lines))
605
- for line in stderr_lines:
606
- logger.error(f"/STDERR {line}")
604
+ if self.stderr_populator:
605
+ stderr_lines = self.stderr_populator.populate()
606
+ self.stderr_populator.increment_counter(len(stderr_lines))
607
+ for line in stderr_lines:
608
+ logger.error(f"/STDERR {line}")
607
609
 
608
610
  @plugin.impl
609
611
  async def on_job_killed(self, scheduler, job):
@@ -767,17 +769,57 @@ class CliGbatchPlugin(CLIPlugin): # pragma: no cover
767
769
  CONFIG_FILES,
768
770
  known_parsed.profile,
769
771
  )
772
+
773
+ def is_valid(val: Any) -> bool:
774
+ """Check if a value is valid (not None, not empty string, not empty list).
775
+ """
776
+ if val is None:
777
+ return False
778
+ if isinstance(val, bool):
779
+ return True
780
+ return bool(val)
781
+
770
782
  # update parsed with the defaults
771
783
  for key, val in defaults.items():
784
+ if (
785
+ key == "mount"
786
+ and val
787
+ and getattr(known_parsed, key, None)
788
+ ):
789
+ if not isinstance(val, (tuple, list)):
790
+ val = [val]
791
+ val = list(val)
792
+
793
+ kp_mount = getattr(known_parsed, key)
794
+ val.extend(kp_mount)
795
+ setattr(known_parsed, key, val)
796
+ continue
797
+
772
798
  if (
773
799
  key == "command"
774
800
  or val is None
775
- or getattr(known_parsed, key, None) is not None
801
+ or is_valid(getattr(known_parsed, key, None))
776
802
  ):
777
803
  continue
778
804
 
779
805
  setattr(known_parsed, key, val)
780
806
 
807
+ mount_as_cwd = getattr(known_parsed, "mount_as_cwd", None)
808
+ cwd = getattr(known_parsed, "cwd", None)
809
+ delattr(known_parsed, "mount_as_cwd")
810
+ if mount_as_cwd and cwd:
811
+ print(
812
+ "\033[1;4mError\033[0m: --mount-as-cwd and --cwd "
813
+ "cannot be used together.\n"
814
+ )
815
+ sys.exit(1)
816
+
817
+ mount = getattr(known_parsed, "mount", None) or []
818
+ if mount_as_cwd:
819
+ mount.append(f"{mount_as_cwd}:/mnt/disks/.cwd")
820
+ setattr(known_parsed, "mount", mount)
821
+ setattr(known_parsed, "cwd", "/mnt/disks/.cwd")
822
+
781
823
  return known_parsed
782
824
 
783
825
  def exec_command(self, args: Namespace) -> None:
@@ -120,7 +120,7 @@ help = "The location to run the job."
120
120
  flags = ["--mount"]
121
121
  # type = "list"
122
122
  default = []
123
- action = "clear_append"
123
+ action = "append"
124
124
  help = """The list of mounts to mount to the VM, each in the format of SOURCE:TARGET, where SOURCE must be either a Google Storage Bucket path (gs://...).
125
125
  You can also use named mounts like `INDIR=gs://my-bucket/inputs` and the directory will be mounted to `/mnt/disks/INDIR` in the VM;
126
126
  then you can use environment variable `$INDIR` in the command/script to refer to the mounted path.
@@ -128,6 +128,14 @@ 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://...).
137
+ """
138
+
131
139
  [[groups.arguments]]
132
140
  flags = ["--service-account"]
133
141
  type = "str"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: pipen-cli-gbatch
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: A pipen cli plugin to run command via Google Cloud Batch
5
5
  License: MIT
6
6
  Author: pwwang
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
16
17
  Requires-Dist: google-cloud-storage (>=3.0.0,<4.0.0)
17
18
  Requires-Dist: pipen (>=0.17.19,<0.18.0)
18
19
  Requires-Dist: pipen-poplog (>=0.3.6,<0.4.0)
@@ -0,0 +1,6 @@
1
+ pipen_cli_gbatch/__init__.py,sha256=2LBMKrJyLLGIjYbquvMyerJYXoD9WJzYgrLEM9yNwEE,30280
2
+ pipen_cli_gbatch/daemon_args.toml,sha256=Yqty1vsNTUQKf411tFTExE1dGM5OHGYcI7ANQm0N-CQ,7170
3
+ pipen_cli_gbatch-0.0.5.dist-info/METADATA,sha256=tD81_KwxU8f-H-AFV7hAAPDj_H8ay7zdG-u93Ezgfmc,11301
4
+ pipen_cli_gbatch-0.0.5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
5
+ pipen_cli_gbatch-0.0.5.dist-info/entry_points.txt,sha256=Z9NLeCpRo-rb8wss5mB5TBcG-_RbdlPA49b8Ma5pvQA,57
6
+ pipen_cli_gbatch-0.0.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,6 +0,0 @@
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,,