icplot 0.1.4__tar.gz → 0.1.5__tar.gz

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.
Files changed (39) hide show
  1. {icplot-0.1.4/src/icplot.egg-info → icplot-0.1.5}/PKG-INFO +12 -4
  2. {icplot-0.1.4 → icplot-0.1.5}/README.md +8 -1
  3. {icplot-0.1.4 → icplot-0.1.5}/pyproject.toml +2 -2
  4. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/convert.py +13 -2
  5. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/main_cli.py +12 -1
  6. icplot-0.1.5/src/icplot/mermaid.py +39 -0
  7. {icplot-0.1.4 → icplot-0.1.5/src/icplot.egg-info}/PKG-INFO +12 -4
  8. {icplot-0.1.4 → icplot-0.1.5}/src/icplot.egg-info/SOURCES.txt +3 -1
  9. icplot-0.1.5/test/test_mermaid.py +24 -0
  10. icplot-0.1.4/test/test_tex_interface.py → icplot-0.1.5/test/test_tex.py +1 -1
  11. {icplot-0.1.4 → icplot-0.1.5}/LICENSE +0 -0
  12. {icplot-0.1.4 → icplot-0.1.5}/setup.cfg +0 -0
  13. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/__init__.py +0 -0
  14. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/cairo_interface.py +0 -0
  15. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/color.py +0 -0
  16. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/gantt/__init__.py +0 -0
  17. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/gantt/gantt.py +0 -0
  18. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/gantt/gantt_renderer.py +0 -0
  19. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/gantt/pgfgantt.py +0 -0
  20. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/geometry.py +0 -0
  21. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/graph/__init__.py +0 -0
  22. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/graph/axis.py +0 -0
  23. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/graph/generator.py +0 -0
  24. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/graph/matplotlib.py +0 -0
  25. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/graph/plot.py +0 -0
  26. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/graph/series.py +0 -0
  27. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/image_utils.py +0 -0
  28. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/py.typed +0 -0
  29. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/tex.py +0 -0
  30. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/trace/__init__.py +0 -0
  31. {icplot-0.1.4 → icplot-0.1.5}/src/icplot/trace/trace.py +0 -0
  32. {icplot-0.1.4 → icplot-0.1.5}/src/icplot.egg-info/dependency_links.txt +0 -0
  33. {icplot-0.1.4 → icplot-0.1.5}/src/icplot.egg-info/entry_points.txt +0 -0
  34. {icplot-0.1.4 → icplot-0.1.5}/src/icplot.egg-info/requires.txt +0 -0
  35. {icplot-0.1.4 → icplot-0.1.5}/src/icplot.egg-info/top_level.txt +0 -0
  36. {icplot-0.1.4 → icplot-0.1.5}/test/test_cairo_interface.py +0 -0
  37. {icplot-0.1.4 → icplot-0.1.5}/test/test_gantt_chart.py +0 -0
  38. {icplot-0.1.4 → icplot-0.1.5}/test/test_image_utils.py +0 -0
  39. {icplot-0.1.4 → icplot-0.1.5}/test/test_line_plots.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: icplot
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Utilities for generating plots and graphics for technical reports.
5
5
  Author-email: "James Grogan, Irish Centre for High End Computing" <james.grogan@ichec.ie>
6
6
  Project-URL: Repository, https://git.ichec.ie/performance/toolshed/icplot
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Topic :: System :: Distributed Computing
14
- Requires-Python: >=3.8
14
+ Requires-Python: >=3.10
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Requires-Dist: wand
@@ -28,6 +28,7 @@ Requires-Dist: pylint; extra == "test"
28
28
  Provides-Extra: cairo
29
29
  Requires-Dist: pycairo; extra == "cairo"
30
30
  Requires-Dist: CairoSVG; extra == "cairo"
31
+ Dynamic: license-file
31
32
 
32
33
  # icplot
33
34
 
@@ -38,8 +39,9 @@ This is a library used at [The Irish Centre for High End Computing (ICHEC)](http
38
39
  The project has support for:
39
40
 
40
41
  * Coverting image formats between pdf, svg and png
41
- * Building pdf output from tex files, including tikz.
42
+ * Building pdf and png output from tex files, including tikz.
42
43
  * Generating plots based on a serializable data model to support reproducible research
44
+ * Generating mermaid plots
43
45
 
44
46
  To covert between image formats you can do:
45
47
 
@@ -53,6 +55,12 @@ To render a Tex tikz image as pdf and png you can do:
53
55
  icplot convert --source my_tikz.tex
54
56
  ```
55
57
 
58
+ To render a Mermaid plot as png you can do:
59
+
60
+ ``` shell
61
+ icplot convert --source my_mermaid.mmd
62
+ ```
63
+
56
64
  To generate a plot or collection of plots from a yaml description you can do:
57
65
 
58
66
  ``` shell
@@ -7,8 +7,9 @@ This is a library used at [The Irish Centre for High End Computing (ICHEC)](http
7
7
  The project has support for:
8
8
 
9
9
  * Coverting image formats between pdf, svg and png
10
- * Building pdf output from tex files, including tikz.
10
+ * Building pdf and png output from tex files, including tikz.
11
11
  * Generating plots based on a serializable data model to support reproducible research
12
+ * Generating mermaid plots
12
13
 
13
14
  To covert between image formats you can do:
14
15
 
@@ -22,6 +23,12 @@ To render a Tex tikz image as pdf and png you can do:
22
23
  icplot convert --source my_tikz.tex
23
24
  ```
24
25
 
26
+ To render a Mermaid plot as png you can do:
27
+
28
+ ``` shell
29
+ icplot convert --source my_mermaid.mmd
30
+ ```
31
+
25
32
  To generate a plot or collection of plots from a yaml description you can do:
26
33
 
27
34
  ``` shell
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "icplot"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  authors = [
5
5
  { name="James Grogan, Irish Centre for High End Computing", email="james.grogan@ichec.ie" },
6
6
  ]
7
7
  description = "Utilities for generating plots and graphics for technical reports."
8
8
  readme = "README.md"
9
- requires-python = ">=3.8"
9
+ requires-python = ">=3.10"
10
10
  classifiers = [
11
11
  "Development Status :: 3 - Alpha",
12
12
  "Programming Language :: Python :: 3",
@@ -1,8 +1,12 @@
1
+ """
2
+ Module supporting conversion between various formats
3
+ """
4
+
1
5
  import logging
2
6
  import os
3
7
  from pathlib import Path
4
8
 
5
- from icplot import tex
9
+ from icplot import tex, mermaid
6
10
  from icplot.tex import TexBuildSettings
7
11
  from icplot.image_utils import pdf_to_png, svg_to_pdf, svg_to_png
8
12
 
@@ -10,7 +14,9 @@ from icplot.image_utils import pdf_to_png, svg_to_pdf, svg_to_png
10
14
  logger = logging.getLogger(__name__)
11
15
 
12
16
 
13
- def convert(source: Path, target: Path, build_dir: Path):
17
+ def convert(
18
+ source: Path, target: Path, build_dir: Path, extra_config: Path | None = None
19
+ ):
14
20
  """
15
21
  Convert the file at source outputing at target and using
16
22
  the source and target file extensions as format hints.
@@ -36,5 +42,10 @@ def convert(source: Path, target: Path, build_dir: Path):
36
42
  target = Path(os.getcwd())
37
43
  settings = TexBuildSettings(source, build_dir, target)
38
44
  tex.build(settings)
45
+ elif source.suffix == ".mmd":
46
+ if not target:
47
+ target = Path(os.getcwd())
48
+ settings = TexBuildSettings(source, build_dir, target)
49
+ mermaid.convert(source, target, extra_config)
39
50
 
40
51
  logger.info("Finished conversion")
@@ -20,7 +20,12 @@ def convert_cli(args):
20
20
  else:
21
21
  target = None
22
22
 
23
- icplot.convert(args.source.resolve(), target, args.buid_dir.resolve())
23
+ if args.extra_config:
24
+ extra_config = Path(args.extra_config).resolve()
25
+ else:
26
+ extra_config = None
27
+
28
+ icplot.convert(args.source.resolve(), target, args.buid_dir.resolve(), extra_config)
24
29
 
25
30
 
26
31
  def plot_cli(args):
@@ -57,6 +62,12 @@ def main_cli():
57
62
  default=Path(os.getcwd()) / "_build/tikz",
58
63
  help="Path for build output",
59
64
  )
65
+ convert_parser.add_argument(
66
+ "--extra_config",
67
+ type=str,
68
+ default="",
69
+ help="Extra config for third party tooling, e.g. puppeteer for mermaid",
70
+ )
60
71
  convert_parser.set_defaults(func=convert_cli)
61
72
 
62
73
  plot_parser = subparsers.add_parser("plot")
@@ -0,0 +1,39 @@
1
+ """
2
+ Interface for generating mermaid plots.
3
+
4
+ Mermaid must already be set up on the system, eg. via the npm ecosystem.
5
+ """
6
+
7
+ import subprocess
8
+ import shutil
9
+ import os
10
+ from pathlib import Path
11
+ import logging
12
+
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+
17
+ def has_mermaid() -> bool:
18
+ """
19
+ True if the mermaid cli is found in the environment
20
+ """
21
+
22
+ return bool(shutil.which("mmdc"))
23
+
24
+
25
+ def convert(input_path: Path, work_dir: Path, browser_config: Path | None = None):
26
+
27
+ if not has_mermaid():
28
+ raise RuntimeError("Mermaid CLI 'mmdc' not found in path.")
29
+
30
+ os.makedirs(work_dir, exist_ok=True)
31
+
32
+ output_path = work_dir / f"{input_path.stem}.png"
33
+
34
+ logger.info("Converting: %s to %s", input_path, output_path)
35
+
36
+ cmd = f"mmdc -i {input_path} -o {output_path}"
37
+ if browser_config:
38
+ cmd += f" -p {browser_config}"
39
+ subprocess.run(cmd, shell=True, check=True)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: icplot
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Utilities for generating plots and graphics for technical reports.
5
5
  Author-email: "James Grogan, Irish Centre for High End Computing" <james.grogan@ichec.ie>
6
6
  Project-URL: Repository, https://git.ichec.ie/performance/toolshed/icplot
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3
11
11
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Topic :: System :: Distributed Computing
14
- Requires-Python: >=3.8
14
+ Requires-Python: >=3.10
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Requires-Dist: wand
@@ -28,6 +28,7 @@ Requires-Dist: pylint; extra == "test"
28
28
  Provides-Extra: cairo
29
29
  Requires-Dist: pycairo; extra == "cairo"
30
30
  Requires-Dist: CairoSVG; extra == "cairo"
31
+ Dynamic: license-file
31
32
 
32
33
  # icplot
33
34
 
@@ -38,8 +39,9 @@ This is a library used at [The Irish Centre for High End Computing (ICHEC)](http
38
39
  The project has support for:
39
40
 
40
41
  * Coverting image formats between pdf, svg and png
41
- * Building pdf output from tex files, including tikz.
42
+ * Building pdf and png output from tex files, including tikz.
42
43
  * Generating plots based on a serializable data model to support reproducible research
44
+ * Generating mermaid plots
43
45
 
44
46
  To covert between image formats you can do:
45
47
 
@@ -53,6 +55,12 @@ To render a Tex tikz image as pdf and png you can do:
53
55
  icplot convert --source my_tikz.tex
54
56
  ```
55
57
 
58
+ To render a Mermaid plot as png you can do:
59
+
60
+ ``` shell
61
+ icplot convert --source my_mermaid.mmd
62
+ ```
63
+
56
64
  To generate a plot or collection of plots from a yaml description you can do:
57
65
 
58
66
  ``` shell
@@ -9,6 +9,7 @@ src/icplot/convert.py
9
9
  src/icplot/geometry.py
10
10
  src/icplot/image_utils.py
11
11
  src/icplot/main_cli.py
12
+ src/icplot/mermaid.py
12
13
  src/icplot/py.typed
13
14
  src/icplot/tex.py
14
15
  src/icplot.egg-info/PKG-INFO
@@ -33,4 +34,5 @@ test/test_cairo_interface.py
33
34
  test/test_gantt_chart.py
34
35
  test/test_image_utils.py
35
36
  test/test_line_plots.py
36
- test/test_tex_interface.py
37
+ test/test_mermaid.py
38
+ test/test_tex.py
@@ -0,0 +1,24 @@
1
+ import shutil
2
+ from pathlib import Path
3
+
4
+ from iccore.test_utils import get_test_data_dir, get_test_output_dir
5
+
6
+ from icplot import mermaid
7
+
8
+
9
+ def test_mermaid():
10
+
11
+ if not mermaid.has_mermaid():
12
+ return
13
+
14
+ # Pass in the browser config so we can also run headless
15
+ # on the CI
16
+ browser_config = Path(__file__).parent.parent / "infra/puppeteer-config.json"
17
+
18
+ output_dir = get_test_output_dir()
19
+ source = get_test_data_dir() / "test.mmd"
20
+
21
+ mermaid.convert(source, output_dir, browser_config)
22
+ assert Path(output_dir / "test.png").exists()
23
+
24
+ shutil.rmtree(output_dir)
@@ -7,7 +7,7 @@ from icplot import tex
7
7
  from icplot.tex import TexBuildSettings
8
8
 
9
9
 
10
- def test_tex_interface():
10
+ def test_tex():
11
11
 
12
12
  data_dir = get_test_data_dir()
13
13
  build_dir = get_test_output_dir()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes