process-intelligence 0.1.0__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.
- process_intelligence-0.1.0.dist-info/METADATA +12 -0
- process_intelligence-0.1.0.dist-info/RECORD +11 -0
- process_intelligence-0.1.0.dist-info/WHEEL +5 -0
- process_intelligence-0.1.0.dist-info/licenses/LICENSE +21 -0
- process_intelligence-0.1.0.dist-info/top_level.txt +2 -0
- src/__init__.py +1 -0
- src/config.py +10 -0
- src/models.py +68 -0
- utils/__init__.py +1 -0
- utils/helpers.py +45 -0
- utils/logger.py +29 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: process-intelligence
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A sample process intelligence Python project.
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Provides-Extra: dev
|
|
8
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
Dynamic: provides-extra
|
|
11
|
+
Dynamic: requires-python
|
|
12
|
+
Dynamic: summary
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
process_intelligence-0.1.0.dist-info/licenses/LICENSE,sha256=Vc2j6xOhJ5ObJfGJh_QEBoQ3CqHhtKi7YE1SdUUFwW0,1086
|
|
2
|
+
src/__init__.py,sha256=uV3ILKFkjpxUZ3w5HS9i5dxnL-gGIMFBzT96lSOETXM,14
|
|
3
|
+
src/config.py,sha256=ChbVdAB7_uIcgxD1FnpJAE00kUPXKusXfPg8XmCTIZ4,206
|
|
4
|
+
src/models.py,sha256=10dASs11qTpe5g8DhPyv8blfhMn9m1IB224gpL40ZVk,1677
|
|
5
|
+
utils/__init__.py,sha256=tVQNbTRSz0iajaKrG6l2c4PAYC8EI8Ay36lakuBS1ik,16
|
|
6
|
+
utils/helpers.py,sha256=CNLpcfMpP5N-tHq5l_e6bXvU2-X8N1neRf-GbSZeqD8,1360
|
|
7
|
+
utils/logger.py,sha256=B4-VtnBcjk1zTw09scg4vgjuKuUJaq3ub_-aUg1Pp84,833
|
|
8
|
+
process_intelligence-0.1.0.dist-info/METADATA,sha256=ewg345LLkecauW_mIV3kZiOctRxqRabg9apm8NOgJXM,316
|
|
9
|
+
process_intelligence-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
10
|
+
process_intelligence-0.1.0.dist-info/top_level.txt,sha256=5Mb2xX8KHYbUg_Pp4EpygSG8s_tthjAsQHAQakp7D3E,10
|
|
11
|
+
process_intelligence-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Process Intelligence Research
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
src/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# src package
|
src/config.py
ADDED
src/models.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Data models for the application."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class Event:
|
|
10
|
+
"""Represents a process event."""
|
|
11
|
+
|
|
12
|
+
event_id: str
|
|
13
|
+
name: str
|
|
14
|
+
timestamp: datetime
|
|
15
|
+
resource: Optional[str] = None
|
|
16
|
+
attributes: dict = field(default_factory=dict)
|
|
17
|
+
|
|
18
|
+
def to_dict(self) -> dict:
|
|
19
|
+
return {
|
|
20
|
+
"event_id": self.event_id,
|
|
21
|
+
"name": self.name,
|
|
22
|
+
"timestamp": self.timestamp.isoformat(),
|
|
23
|
+
"resource": self.resource,
|
|
24
|
+
"attributes": self.attributes,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class Case:
|
|
30
|
+
"""Represents a process case (trace)."""
|
|
31
|
+
|
|
32
|
+
case_id: str
|
|
33
|
+
events: List[Event] = field(default_factory=list)
|
|
34
|
+
|
|
35
|
+
def add_event(self, event: Event) -> None:
|
|
36
|
+
self.events.append(event)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def duration(self) -> Optional[float]:
|
|
40
|
+
if len(self.events) < 2:
|
|
41
|
+
return None
|
|
42
|
+
start = min(e.timestamp for e in self.events)
|
|
43
|
+
end = max(e.timestamp for e in self.events)
|
|
44
|
+
return (end - start).total_seconds()
|
|
45
|
+
|
|
46
|
+
def __len__(self) -> int:
|
|
47
|
+
return len(self.events)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class ProcessLog:
|
|
52
|
+
"""Collection of cases forming a process event log."""
|
|
53
|
+
|
|
54
|
+
log_id: str
|
|
55
|
+
cases: List[Case] = field(default_factory=list)
|
|
56
|
+
|
|
57
|
+
def add_case(self, case: Case) -> None:
|
|
58
|
+
self.cases.append(case)
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def num_events(self) -> int:
|
|
62
|
+
return sum(len(c) for c in self.cases)
|
|
63
|
+
|
|
64
|
+
def get_case(self, case_id: str) -> Optional[Case]:
|
|
65
|
+
for case in self.cases:
|
|
66
|
+
if case.case_id == case_id:
|
|
67
|
+
return case
|
|
68
|
+
return None
|
utils/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# utils package
|
utils/helpers.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Miscellaneous helper utilities."""
|
|
2
|
+
|
|
3
|
+
import uuid
|
|
4
|
+
import hashlib
|
|
5
|
+
from typing import Any, List
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def generate_id(prefix: str = "") -> str:
|
|
9
|
+
"""Return a short unique identifier with an optional prefix."""
|
|
10
|
+
uid = uuid.uuid4().hex[:8]
|
|
11
|
+
return f"{prefix}-{uid}" if prefix else uid
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def format_duration(seconds: float) -> str:
|
|
15
|
+
"""Convert a duration in seconds to a human-readable string."""
|
|
16
|
+
if seconds < 60:
|
|
17
|
+
return f"{seconds:.1f}s"
|
|
18
|
+
minutes, secs = divmod(seconds, 60)
|
|
19
|
+
if minutes < 60:
|
|
20
|
+
return f"{int(minutes)}m {int(secs)}s"
|
|
21
|
+
hours, mins = divmod(minutes, 60)
|
|
22
|
+
return f"{int(hours)}h {int(mins)}m"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def flatten(nested: List[Any]) -> List[Any]:
|
|
26
|
+
"""Recursively flatten a nested list."""
|
|
27
|
+
result: List[Any] = []
|
|
28
|
+
for item in nested:
|
|
29
|
+
if isinstance(item, list):
|
|
30
|
+
result.extend(flatten(item))
|
|
31
|
+
else:
|
|
32
|
+
result.append(item)
|
|
33
|
+
return result
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def compute_checksum(data: str) -> str:
|
|
37
|
+
"""Return the SHA-256 hex digest of the given string."""
|
|
38
|
+
return hashlib.sha256(data.encode()).hexdigest()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def chunk_list(lst: List[Any], size: int) -> List[List[Any]]:
|
|
42
|
+
"""Split *lst* into consecutive chunks of *size* elements."""
|
|
43
|
+
if size <= 0:
|
|
44
|
+
raise ValueError("Chunk size must be a positive integer.")
|
|
45
|
+
return [lst[i : i + size] for i in range(0, len(lst), size)]
|
utils/logger.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Lightweight logging wrapper."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_logger(name: str, level: str = "INFO") -> logging.Logger:
|
|
8
|
+
"""Return a configured :class:`logging.Logger` instance.
|
|
9
|
+
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
name:
|
|
13
|
+
Logger name, typically ``__name__``.
|
|
14
|
+
level:
|
|
15
|
+
Logging level as a string (e.g. ``"DEBUG"``, ``"INFO"``).
|
|
16
|
+
"""
|
|
17
|
+
logger = logging.getLogger(name)
|
|
18
|
+
if not logger.handlers:
|
|
19
|
+
handler = logging.StreamHandler(sys.stdout)
|
|
20
|
+
formatter = logging.Formatter(
|
|
21
|
+
fmt="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
22
|
+
datefmt="%Y-%m-%dT%H:%M:%S",
|
|
23
|
+
)
|
|
24
|
+
handler.setFormatter(formatter)
|
|
25
|
+
logger.addHandler(handler)
|
|
26
|
+
|
|
27
|
+
numeric_level = getattr(logging, level.upper(), logging.INFO)
|
|
28
|
+
logger.setLevel(numeric_level)
|
|
29
|
+
return logger
|