HowdenPipeline 0.0.3__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.
@@ -0,0 +1,64 @@
1
+ from pathlib import Path
2
+ from collections import defaultdict
3
+ import os
4
+ import json
5
+
6
+ class GraphPipeline:
7
+ def __init__(self, root_folder: str):
8
+ self.root_folder = Path(root_folder)
9
+
10
+ self.graph = defaultdict(list)
11
+ self.nodes = {}
12
+
13
+ def add_node(self, cls, dependencies=None):
14
+ name = cls.__class__.__name__
15
+ identity = hex(id(cls))
16
+ self.nodes[identity] = cls
17
+ if dependencies:
18
+ for dep in dependencies:
19
+ dependent_identity = hex(id(dep))
20
+ dep_name = dependent_identity if isinstance(dep, type) else dep
21
+ self.graph[dep_name].append(name)
22
+ else:
23
+ self.graph[identity] = self.graph.get(identity, [])
24
+
25
+ def execute(self):
26
+
27
+ pdf_files = list(self.root_folder.rglob("*.pdf"))
28
+
29
+ for pdf_file in pdf_files:
30
+ for name, step in self.nodes.items():
31
+ if name in self.graph.keys():
32
+ hash_ = self.compute_hash(step)
33
+ path = Path(pdf_file.parent / hash_)
34
+ path.mkdir(parents=True, exist_ok=True)
35
+ file_path = path / Path(pdf_file.name).with_suffix(".md")
36
+ if file_path.exists():
37
+ result = file_path.read_text(encoding="utf-8")
38
+ else:
39
+ result = step(pdf_file)
40
+ file_path.write_text(result, encoding="utf-8")
41
+ json_parameter = file_path.parent / "paramter.json"
42
+ attrs = {k: v for k, v in step.__dict__.items() if not k.startswith('_')}
43
+ json_parameter.write_text(json.dumps(attrs), encoding="utf-8")
44
+ else:
45
+ result = file_path.read_text(encoding="utf-8")
46
+ result = step(result)
47
+ print(result)
48
+
49
+
50
+ #outputs = self._process_single_pdf(pdf_path, max_cycles)
51
+
52
+ #output_file = self.output_folder / f"{subfolder.name}.json"
53
+ #with open(output_file, "w", encoding="utf-8") as f:
54
+ # json.dump(outputs, f, indent=2)
55
+
56
+ @staticmethod
57
+ def compute_hash(cls) -> str:
58
+ import hashlib
59
+ # Collect all instance attributes
60
+ attrs = {k: v for k, v in cls.__dict__.items() if k != "hash"}
61
+ # Convert to JSON string for a stable representation
62
+ attrs_str = json.dumps(attrs, sort_keys=True, default=str)
63
+ # Return SHA256 hash
64
+ return hashlib.sha256(attrs_str.encode()).hexdigest()
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.3
2
+ Name: HowdenPipeline
3
+ Version: 0.0.3
4
+ Summary: A simple configuration manager with Pydantic and JSON export.
5
+ License: MIT
6
+ Keywords: config,configuration,pydantic,json
7
+ Author: JesperThoftIllemannJ
8
+ Author-email: jesper.jaeger@howdendanmark.dk
9
+ Requires-Python: >=3.12,<3.14
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: howdenconfig (>=1.0.6,<2.0.0)
15
+ Requires-Dist: howdenllm (==0.1.24)
16
+ Requires-Dist: howdenparser (>=2.0.1,<3.0.0)
17
+ Project-URL: Documentation, https://github.com/yourusername/config
18
+ Project-URL: Homepage, https://github.com/yourusername/config
19
+ Project-URL: Repository, https://github.com/yourusername/config
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Introduction
23
+ TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
24
+
25
+ # Getting Started
26
+ TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
27
+ 1. Installation process
28
+ 2. Software dependencies
29
+ 3. Latest releases
30
+ 4. API references
31
+
32
+ # Build and Test
33
+ TODO: Describe and show how to build your code and run the tests.
34
+
35
+ # Contribute
36
+ TODO: Explain how other users and developers can contribute to make your code better.
37
+
38
+ If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
39
+ - [ASP.NET Core](https://github.com/aspnet/Home)
40
+ - [Visual Studio Code](https://github.com/Microsoft/vscode)
41
+ - [Chakra Core](https://github.com/Microsoft/ChakraCore)
@@ -0,0 +1,20 @@
1
+ # Introduction
2
+ TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
3
+
4
+ # Getting Started
5
+ TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
6
+ 1. Installation process
7
+ 2. Software dependencies
8
+ 3. Latest releases
9
+ 4. API references
10
+
11
+ # Build and Test
12
+ TODO: Describe and show how to build your code and run the tests.
13
+
14
+ # Contribute
15
+ TODO: Explain how other users and developers can contribute to make your code better.
16
+
17
+ If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
18
+ - [ASP.NET Core](https://github.com/aspnet/Home)
19
+ - [Visual Studio Code](https://github.com/Microsoft/vscode)
20
+ - [Chakra Core](https://github.com/Microsoft/ChakraCore)
@@ -0,0 +1,28 @@
1
+ [project]
2
+ name = "HowdenPipeline"
3
+ description = ""
4
+ readme = "README.md"
5
+ requires-python = ">=3.12,<3.14"
6
+ dependencies = [ "howdenconfig (>=1.0.6,<2.0.0)", "howdenparser (>=2.0.1,<3.0.0)", "howdenllm (==0.1.24)",]
7
+ [[project.authors]]
8
+ name = "JesperThoftIllemannJ"
9
+ email = "jesper.jaeger@howdendanmark.dk"
10
+
11
+ [build-system]
12
+ requires = [ "poetry-core>=2.0.0,<3.0.0",]
13
+ build-backend = "poetry.core.masonry.api"
14
+
15
+ [tool.poetry]
16
+ name = "HowdenPipeline"
17
+ version = "0.0.3"
18
+ description = "A simple configuration manager with Pydantic and JSON export."
19
+ authors = [ "JesperThoftIllemannJ <jesper.jaeger@howdendanmark.dk>",]
20
+ readme = "README.md"
21
+ license = "MIT"
22
+ keywords = [ "config", "configuration", "pydantic", "json",]
23
+ homepage = "https://github.com/yourusername/config"
24
+ repository = "https://github.com/yourusername/config"
25
+ documentation = "https://github.com/yourusername/config"
26
+ [[tool.poetry.packages]]
27
+ include = "HowdenPipeline"
28
+