ladyrick 0.5.2__py3-none-any.whl → 0.5.4__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.
ladyrick/__init__.py CHANGED
@@ -6,7 +6,20 @@ from typing import TYPE_CHECKING
6
6
  def __getattr__(name):
7
7
  from importlib import import_module
8
8
 
9
- if name in ("pretty_print",):
9
+ if name in (
10
+ "allgather",
11
+ "debug",
12
+ "loader",
13
+ "pickle",
14
+ "pprint",
15
+ "print_utils",
16
+ "torch",
17
+ "typing",
18
+ "utils",
19
+ "vars",
20
+ ):
21
+ return import_module(f"ladyrick.{name}")
22
+ elif name in ("pretty_print",):
10
23
  m = import_module("ladyrick.pprint")
11
24
  elif name in ("class_name", "utc_8_now", "get_timestr"):
12
25
  m = import_module("ladyrick.utils")
@@ -33,3 +46,13 @@ if TYPE_CHECKING:
33
46
  from ladyrick.typing import type_like # noqa
34
47
  from ladyrick.utils import class_name, get_timestr, utc_8_now # noqa
35
48
  from ladyrick.vars import Dump, V, Vars, dump # noqa
49
+ from ladyrick import allgather # noqa
50
+ from ladyrick import debug # noqa
51
+ from ladyrick import loader # noqa
52
+ from ladyrick import pickle # noqa
53
+ from ladyrick import pprint # noqa
54
+ from ladyrick import print_utils # noqa
55
+ from ladyrick import torch # noqa
56
+ from ladyrick import typing # noqa
57
+ from ladyrick import utils # noqa
58
+ from ladyrick import vars # noqa
ladyrick/cli/calc.py ADDED
@@ -0,0 +1,42 @@
1
+ import os
2
+ import sys
3
+
4
+
5
+ def initialize(interactive_mode: bool):
6
+ imports = {}
7
+ exec("import ladyrick.patch.rich_print")
8
+ exec("import math; from math import *", None, imports)
9
+ exec("import itertools; from itertools import *", None, imports)
10
+ exec("import functools; from functools import cache, lru_cache, partial, reduce", None, imports)
11
+ exec("import os, sys, time, re, random", None, imports)
12
+ exec("from pathlib import Path", None, imports)
13
+ exec("from time import sleep", None, imports)
14
+ exec("from subprocess import check_output", None, imports)
15
+ exec("from random import randint, choice, random as rand", None, imports)
16
+ exec("import ladyrick", None, imports)
17
+ if interactive_mode:
18
+ imports["ladyrick"].pprint.reg_ipython_cmd()
19
+ globals().update(imports)
20
+
21
+
22
+ def main():
23
+ if len(sys.argv) == 1 and not os.getenv("__ladyrick_calc__"):
24
+ import setproctitle
25
+
26
+ os.environ["__ladyrick_calc__"] = setproctitle.getproctitle()
27
+ os.execl(sys.executable, sys.executable, "-m", "IPython", "-i", "--no-banner", "--no-confirm-exit", __file__)
28
+ else:
29
+ if len(sys.argv) == 1:
30
+ import setproctitle
31
+
32
+ setproctitle.setproctitle(os.environ["__ladyrick_calc__"])
33
+ del setproctitle
34
+
35
+ initialize(len(sys.argv) == 1)
36
+
37
+ if len(sys.argv) > 1:
38
+ print(eval(" ".join(sys.argv[1:])))
39
+
40
+
41
+ if __name__ == "__main__":
42
+ main()
ladyrick/cli/multi_ssh.py CHANGED
@@ -21,7 +21,7 @@ def force_kill(child: subprocess.Popen, child_pgid):
21
21
  child.kill() # kill -9
22
22
 
23
23
 
24
- REMOTE_HEAD_PROG_NAME = "ladyrick-remote-head"
24
+ REMOTE_HEAD_PROG_NAME = "ladyrick/multi-ssh/remote-head"
25
25
 
26
26
 
27
27
  def remote_head():
ladyrick/pprint.py CHANGED
@@ -251,6 +251,17 @@ def pretty_print(model):
251
251
  Printer().print(model, FakeRichStream())
252
252
 
253
253
 
254
+ def reg_ipython_cmd():
255
+ from IPython.core.magic import register_line_magic
256
+
257
+ @register_line_magic
258
+ def pp(line: str):
259
+ if line.strip():
260
+ pretty_print(eval(line))
261
+ else:
262
+ rich_print("pp is pretty_print.\nusage: pp <exps>")
263
+
264
+
254
265
  @dataclasses.dataclass
255
266
  class load_failed:
256
267
  file: str
@@ -321,12 +332,7 @@ def main():
321
332
  if "torch" in sys.modules:
322
333
  add_to_globals["torch"] = sys.modules["torch"]
323
334
  globals().update(add_to_globals)
324
-
325
- from IPython.core.magic import register_line_magic
326
-
327
- @register_line_magic
328
- def pp(line):
329
- pretty_print(eval(line))
335
+ reg_ipython_cmd()
330
336
 
331
337
 
332
338
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ladyrick
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: ladyrick's tools
5
5
  Author-email: ladyrick <ladyrick@qq.com>
6
6
  License-Expression: MIT
@@ -1,15 +1,16 @@
1
- ladyrick/__init__.py,sha256=udDiOLu2L1jIvjgSCLdDsTnS2OA7kdj2BA9kit2maVo,1343
1
+ ladyrick/__init__.py,sha256=wkastx1reQfUUtx9n5cW-CM-9f0F0uX7Qek2vex782s,2004
2
2
  ladyrick/allgather.py,sha256=jhu6eYABIwdl2WTKbK9UR9ji8imhUIdGd-ITPfluYm0,3531
3
3
  ladyrick/debug.py,sha256=jMVdL9cg1yFaX6Yfdw0Yq6LZMOl7av-DnpaR51eEV38,3083
4
4
  ladyrick/loader.py,sha256=Ykg4yxK-UlhAGpBJnnHQLecEMkDpQETOenIs2okwdGY,2263
5
5
  ladyrick/pickle.py,sha256=AjIm4H2_3bPOW-NPd9ow_sA3Z520LZwf1VeX6742ADs,2147
6
- ladyrick/pprint.py,sha256=E_oginnkLmYbvDKzm82KujkqSSjIcFhjU21-l1Wo-Qk,11350
6
+ ladyrick/pprint.py,sha256=K9nzrO9pkQ0smgLDEMmSAm9_MZCgqYGFT-XCwVZFn_o,11496
7
7
  ladyrick/print_utils.py,sha256=NRalqrTy8PWj1tL2K2wAlXbQpiX1_N7P0-rQ9kmmHEQ,3472
8
8
  ladyrick/torch.py,sha256=CEdHYaOZ00StZettf4MoIB3tMF0fbzSIH-3pOqOMIZM,1977
9
9
  ladyrick/typing.py,sha256=YQeApe63dk7yL4NS5ytlR6v3dLCii2-qsXNlUvjK-zw,203
10
10
  ladyrick/utils.py,sha256=jRRaqC6kNbCJPGeE0YisFgis-wiuINLik1mcUQtytow,608
11
11
  ladyrick/vars.py,sha256=VbFh2u7XybUaBuiYEXBa4sOmoS99vc2AIXdYLBh8vjk,3763
12
- ladyrick/cli/multi_ssh.py,sha256=faRIgradz3e6ZjwpPd77OB_u5FEJFCfVzGq3qrwJsgk,9220
12
+ ladyrick/cli/calc.py,sha256=5_UhSSaL_K9FBCHg3zuCk41CHJXy3QAh__qCabbffQY,1438
13
+ ladyrick/cli/multi_ssh.py,sha256=wbO7woW0roAd6Q5LW861c8h5r7sfkCKW2qvCq-HssTY,9230
13
14
  ladyrick/cli/psf.py,sha256=JLk3gbPn7E3uuPBbzGvLgJmFQlilA6zg_Xlg7xW5jik,1146
14
15
  ladyrick/cli/tee.py,sha256=UMJxSJLOEfbV43auVKRTIJ5ZAMAkAfj8byiFLk5PUHE,3579
15
16
  ladyrick/cli/test_args.py,sha256=f5sUPDlcf6nbNf6UfLwZQI5g5LN8wlFBQZ10GLw22cg,212
@@ -20,9 +21,9 @@ ladyrick/patch/rich_print.py,sha256=z3Ea1VCunXZvNvEDFHpoyWc8ydINmh-gOIJ1ssscs6s,
20
21
  ladyrick/patch/python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
22
  ladyrick/patch/python/__main__.py,sha256=BAGy1phd26WWcGM9TKHbqIpeZliVofopBndtMIPtDQ0,651
22
23
  ladyrick/patch/python/usercustomize.py,sha256=8mYpcZ8p-l41fiSJue727n8cAmcEmUktObDYZDdLJfs,218
23
- ladyrick-0.5.2.dist-info/licenses/LICENSE,sha256=EeNAFxYAOYEmo2YEM7Zk5Oknq4RI0XMAbk4Rgoem6fs,1065
24
- ladyrick-0.5.2.dist-info/METADATA,sha256=K3kyX7wNOmge7CX0mZl7HtOWl3ai9GVFFfOdN7gkUtA,883
25
- ladyrick-0.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- ladyrick-0.5.2.dist-info/entry_points.txt,sha256=WVddlz7Wn9t1kQkA-HluVeeyKRJB3-7KrRpmWxfR2cM,195
27
- ladyrick-0.5.2.dist-info/top_level.txt,sha256=RIC3-Jty2qzLYXSOr7fOu1loTwlMU9cF6MFeGIROxWU,9
28
- ladyrick-0.5.2.dist-info/RECORD,,
24
+ ladyrick-0.5.4.dist-info/licenses/LICENSE,sha256=EeNAFxYAOYEmo2YEM7Zk5Oknq4RI0XMAbk4Rgoem6fs,1065
25
+ ladyrick-0.5.4.dist-info/METADATA,sha256=lAnPzvF3RUZk9942XC-UDUMZuiD77o_h6LFRZx2jj-c,883
26
+ ladyrick-0.5.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ ladyrick-0.5.4.dist-info/entry_points.txt,sha256=28kidI1OCOAi7S1aHBr8veak49VNZ0tWFvf-Ty8UmSU,225
28
+ ladyrick-0.5.4.dist-info/top_level.txt,sha256=RIC3-Jty2qzLYXSOr7fOu1loTwlMU9cF6MFeGIROxWU,9
29
+ ladyrick-0.5.4.dist-info/RECORD,,
@@ -1,5 +1,6 @@
1
1
  [console_scripts]
2
2
  allgather = ladyrick.allgather:main
3
+ calc = ladyrick.cli.calc:main
3
4
  ladyrick-tee = ladyrick.cli.tee:main
4
5
  multi-ssh = ladyrick.cli.multi_ssh:main
5
6
  pretty-print = ladyrick.pprint:main