tagaudit 0.1.1__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.
- tagaudit-0.1.1/LICENSE +201 -0
- tagaudit-0.1.1/PKG-INFO +183 -0
- tagaudit-0.1.1/README.md +153 -0
- tagaudit-0.1.1/pyproject.toml +47 -0
- tagaudit-0.1.1/setup.cfg +4 -0
- tagaudit-0.1.1/src/tagaudit/__init__.py +3 -0
- tagaudit-0.1.1/src/tagaudit/__main__.py +3 -0
- tagaudit-0.1.1/src/tagaudit/audit.py +347 -0
- tagaudit-0.1.1/src/tagaudit/cli.py +149 -0
- tagaudit-0.1.1/src/tagaudit/infer.py +91 -0
- tagaudit-0.1.1/src/tagaudit/opcua.py +316 -0
- tagaudit-0.1.1/src/tagaudit/report.py +162 -0
- tagaudit-0.1.1/src/tagaudit/series.py +447 -0
- tagaudit-0.1.1/src/tagaudit.egg-info/PKG-INFO +183 -0
- tagaudit-0.1.1/src/tagaudit.egg-info/SOURCES.txt +24 -0
- tagaudit-0.1.1/src/tagaudit.egg-info/dependency_links.txt +1 -0
- tagaudit-0.1.1/src/tagaudit.egg-info/entry_points.txt +2 -0
- tagaudit-0.1.1/src/tagaudit.egg-info/requires.txt +9 -0
- tagaudit-0.1.1/src/tagaudit.egg-info/top_level.txt +1 -0
- tagaudit-0.1.1/tests/test_audit.py +218 -0
- tagaudit-0.1.1/tests/test_audit_extensions.py +79 -0
- tagaudit-0.1.1/tests/test_cli.py +174 -0
- tagaudit-0.1.1/tests/test_opcua_binary_read.py +66 -0
- tagaudit-0.1.1/tests/test_opcua_collect.py +172 -0
- tagaudit-0.1.1/tests/test_opcua_read_contract.py +55 -0
- tagaudit-0.1.1/tests/test_series.py +215 -0
tagaudit-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
tagaudit-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tagaudit
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Check industrial tag data before you trust it: units, ranges, quality codes, timestamps, gaps and stuck values in OPC UA captures and historian CSV exports.
|
|
5
|
+
Author: Sankalp Thakur
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/sankalpsthakur/tagaudit
|
|
8
|
+
Project-URL: Issues, https://github.com/sankalpsthakur/tagaudit/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/sankalpsthakur/tagaudit/blob/main/CHANGELOG.md
|
|
10
|
+
Keywords: opc-ua,historian,scada,data-quality,iiot,telemetry,industrial,time-series
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Manufacturing
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: tzdata; sys_platform == "win32"
|
|
25
|
+
Provides-Extra: opcua
|
|
26
|
+
Requires-Dist: asyncua==2.0.1; extra == "opcua"
|
|
27
|
+
Provides-Extra: test
|
|
28
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# tagaudit
|
|
32
|
+
|
|
33
|
+
[](https://github.com/sankalpsthakur/tagaudit/actions/workflows/ci.yml)
|
|
34
|
+
[](https://pypi.org/project/tagaudit/)
|
|
35
|
+
[](https://pypi.org/project/tagaudit/)
|
|
36
|
+
[](https://github.com/sankalpsthakur/tagaudit/blob/main/LICENSE)
|
|
37
|
+
|
|
38
|
+
Check industrial tag data before you trust it.
|
|
39
|
+
|
|
40
|
+
`tagaudit` reads a historian CSV export or an OPC UA capture and tells you which values to
|
|
41
|
+
distrust and why:
|
|
42
|
+
|
|
43
|
+
- wrong units and values outside the declared range
|
|
44
|
+
- bad or uncertain quality codes
|
|
45
|
+
- text where a number should be (`I/O Timeout`, `Bad Input`)
|
|
46
|
+
- duplicate and backwards timestamps
|
|
47
|
+
- gaps and stuck values
|
|
48
|
+
- local times that happen twice, or never, when the clocks change
|
|
49
|
+
|
|
50
|
+
It runs on your machine, needs only Python 3.10+, and never writes to a PLC or server.
|
|
51
|
+
|
|
52
|
+
## Quick start
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install tagaudit
|
|
56
|
+
tagaudit check export.csv
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Without a profile, `tagaudit` works out the layout and checks what the file alone can prove.
|
|
60
|
+
To check ranges, quality codes, gaps and stuck values, write a profile and edit it:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
tagaudit init export.csv -o profile.json # lists tags and units; you add limits
|
|
64
|
+
tagaudit check export.csv --profile profile.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Output for [`examples/historian-long.csv`](https://github.com/sankalpsthakur/tagaudit/blob/main/examples/historian-long.csv) with
|
|
68
|
+
[`examples/historian-profile.json`](https://github.com/sankalpsthakur/tagaudit/blob/main/examples/historian-profile.json):
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
tagaudit 0.1.0 · historian-long.csv · long export · asset pump-station-1
|
|
72
|
+
2026-10-24T23:59:40Z to 2026-10-24T23:59:58Z (UTC)
|
|
73
|
+
|
|
74
|
+
FAIL 10 of 20 values rejected
|
|
75
|
+
|
|
76
|
+
Problems
|
|
77
|
+
ambiguous_local_time 2 local time happens twice (clocks went back)
|
|
78
|
+
line 19 PT-101 = 8.07 at 2026-10-25 02:00:01
|
|
79
|
+
line 20 FT-102 = 42.0 at 2026-10-25 02:00:01
|
|
80
|
+
gap_exceeds_limit 2 gap since the previous value exceeds max_gap_seconds
|
|
81
|
+
line 17 PT-101 = 8.06 at 2026-10-25 01:59:58
|
|
82
|
+
line 18 FT-102 = 41.9 at 2026-10-25 01:59:58
|
|
83
|
+
duplicate_timestamp 1 same tag twice at the same time
|
|
84
|
+
line 12 PT-101 = 8.04 at 2026-10-25 01:59:44
|
|
85
|
+
nonfinite_or_nonnumeric_value 1 value is not a number
|
|
86
|
+
line 9 FT-102 = I/O Timeout at 2026-10-25 01:59:43
|
|
87
|
+
outside_engineering_range 1 value outside the declared range
|
|
88
|
+
line 6 PT-101 = 803 at 2026-10-25 01:59:42
|
|
89
|
+
quality_bad 1 quality code says bad
|
|
90
|
+
line 9 FT-102 = I/O Timeout at 2026-10-25 01:59:43
|
|
91
|
+
quality_uncertain 1 quality code says uncertain
|
|
92
|
+
line 11 FT-102 = 41.8 at 2026-10-25 01:59:44
|
|
93
|
+
stuck_value 1 value unchanged for more than max_repeats samples
|
|
94
|
+
line 16 FT-102 = 41.8 at 2026-10-25 01:59:48
|
|
95
|
+
timestamp_went_backwards 1 earlier than this tag's previous value
|
|
96
|
+
line 21 PT-101 = 8.06 at 2026-10-25 01:59:50
|
|
97
|
+
unit_mismatch 1 unit differs from the profile
|
|
98
|
+
line 6 PT-101 = 803 at 2026-10-25 01:59:42
|
|
99
|
+
|
|
100
|
+
Not checked
|
|
101
|
+
freshness exports carry no receive time, so data age at the edge is unknown
|
|
102
|
+
sample_groups long export is not declared synchronized
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Exit codes: `0` all checks passed, `2` problems found, `1` the file or profile couldn't be
|
|
106
|
+
read. Add `--output report.json` for a JSON report, or `--json` to print it.
|
|
107
|
+
|
|
108
|
+
## What it reads
|
|
109
|
+
|
|
110
|
+
| Layout | Looks like | Notes |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| Long | `Timestamp,TagName,Value,Quality,Units` | One value per row. Quality and unit columns are optional. |
|
|
113
|
+
| Wide | `Timestamp,PT-101,FT-102` | One column per tag. A blank cell counts as a missing value in that row. |
|
|
114
|
+
| Native capture | written by `tagaudit collect` | Adds OPC UA source, server and receive timestamps, so freshness can be checked. |
|
|
115
|
+
|
|
116
|
+
For wide and synchronized long exports, the report also counts missing values per tag and
|
|
117
|
+
names the tags that are empty in every row.
|
|
118
|
+
|
|
119
|
+
Each file needs one column holding the full date and time. Exports that split date and time
|
|
120
|
+
across several columns aren't supported yet. Timestamps can be ISO 8601 with or without a UTC
|
|
121
|
+
offset, epoch seconds or milliseconds, or any `strptime` pattern. If they have no offset, set `input.timezone` (`UTC`, `+04:00` or a zone
|
|
122
|
+
such as `Europe/Berlin`). With a named zone, `tagaudit` flags times that occur twice or never
|
|
123
|
+
during clock changes.
|
|
124
|
+
|
|
125
|
+
## Profiles
|
|
126
|
+
|
|
127
|
+
A profile says what the data should look like. `tagaudit init` writes the layout, tags and
|
|
128
|
+
units it finds. It leaves the rest for you, because guessing them would make those checks
|
|
129
|
+
meaningless.
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"schema": "tagaudit.profile.v1",
|
|
134
|
+
"quality_encoding": "opc_da_quality",
|
|
135
|
+
"max_gap_seconds": 5,
|
|
136
|
+
"max_repeats": 3,
|
|
137
|
+
"input": {"format": "long", "timestamp": "Timestamp", "tag": "TagName", "value": "Value",
|
|
138
|
+
"quality": "Quality", "unit": "Units", "timezone": "Europe/Berlin"},
|
|
139
|
+
"tags": [
|
|
140
|
+
{"name": "PT-101", "unit": "bar", "minimum": 0, "maximum": 16},
|
|
141
|
+
{"name": "FT-102", "unit": "m3/h", "minimum": 0, "maximum": 120, "max_gap_seconds": 10}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- `quality_encoding`: `opcua_status_code` (0 is good), `opc_da_quality` (192 is good, 0 is
|
|
147
|
+
bad) or `quality_words` (`good`, `uncertain`, `bad`). The two numeric schemes read 0 in
|
|
148
|
+
opposite ways, so `tagaudit` never guesses.
|
|
149
|
+
- `minimum` and `maximum`: either or both. Tags without them are listed under "Not checked".
|
|
150
|
+
- `max_gap_seconds`: the longest silence allowed between values of a tag.
|
|
151
|
+
- `max_repeats`: how many times in a row a value may repeat before it counts as stuck.
|
|
152
|
+
Per-tag values override the profile-wide ones.
|
|
153
|
+
- Wide exports map tag names to columns with `"input": {"format": "wide", "columns": {"PT-101": "Pump01/Pressure"}}`.
|
|
154
|
+
|
|
155
|
+
## OPC UA captures
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install "tagaudit[opcua]"
|
|
159
|
+
tagaudit collect --profile capture-profile.json --endpoint opc.tcp://192.168.0.10:4840 \
|
|
160
|
+
--certificate client.pem --private-key client-key.pem --server-certificate server.der \
|
|
161
|
+
--csv capture.csv --output capture.audit.json
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The collector only reads: it exposes no Write or Call service, and it takes a bounded number
|
|
165
|
+
of samples (`--samples`, default 5). It records each value's source, server and receive
|
|
166
|
+
timestamps, so the audit can tell a fresh server timestamp on an old value from genuinely new
|
|
167
|
+
data. Use a server-side read-only role as well, because client code is not access control.
|
|
168
|
+
[`examples/capture-faults.csv`](https://github.com/sankalpsthakur/tagaudit/blob/main/examples/capture-faults.csv) shows the checks on a capture.
|
|
169
|
+
|
|
170
|
+
For machines without `pip`, copy `audit.py` out of the repository or the wheel. It runs on
|
|
171
|
+
its own with the standard library and checks native captures:
|
|
172
|
+
`python audit.py --profile profile.json --csv capture.csv --output report.json`.
|
|
173
|
+
|
|
174
|
+
## What a pass does not mean
|
|
175
|
+
|
|
176
|
+
A pass means the file matches its profile. It doesn't show that sensors are calibrated, that
|
|
177
|
+
the source was authentic, that an export is still current, or that a model trained on the data
|
|
178
|
+
will behave. Checks the file can't support are listed under "Not checked" instead of being
|
|
179
|
+
skipped silently.
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
Apache-2.0. Copyright 2026 Sankalp Thakur.
|
tagaudit-0.1.1/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# tagaudit
|
|
2
|
+
|
|
3
|
+
[](https://github.com/sankalpsthakur/tagaudit/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/tagaudit/)
|
|
5
|
+
[](https://pypi.org/project/tagaudit/)
|
|
6
|
+
[](https://github.com/sankalpsthakur/tagaudit/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
Check industrial tag data before you trust it.
|
|
9
|
+
|
|
10
|
+
`tagaudit` reads a historian CSV export or an OPC UA capture and tells you which values to
|
|
11
|
+
distrust and why:
|
|
12
|
+
|
|
13
|
+
- wrong units and values outside the declared range
|
|
14
|
+
- bad or uncertain quality codes
|
|
15
|
+
- text where a number should be (`I/O Timeout`, `Bad Input`)
|
|
16
|
+
- duplicate and backwards timestamps
|
|
17
|
+
- gaps and stuck values
|
|
18
|
+
- local times that happen twice, or never, when the clocks change
|
|
19
|
+
|
|
20
|
+
It runs on your machine, needs only Python 3.10+, and never writes to a PLC or server.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install tagaudit
|
|
26
|
+
tagaudit check export.csv
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Without a profile, `tagaudit` works out the layout and checks what the file alone can prove.
|
|
30
|
+
To check ranges, quality codes, gaps and stuck values, write a profile and edit it:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
tagaudit init export.csv -o profile.json # lists tags and units; you add limits
|
|
34
|
+
tagaudit check export.csv --profile profile.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Output for [`examples/historian-long.csv`](https://github.com/sankalpsthakur/tagaudit/blob/main/examples/historian-long.csv) with
|
|
38
|
+
[`examples/historian-profile.json`](https://github.com/sankalpsthakur/tagaudit/blob/main/examples/historian-profile.json):
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
tagaudit 0.1.0 · historian-long.csv · long export · asset pump-station-1
|
|
42
|
+
2026-10-24T23:59:40Z to 2026-10-24T23:59:58Z (UTC)
|
|
43
|
+
|
|
44
|
+
FAIL 10 of 20 values rejected
|
|
45
|
+
|
|
46
|
+
Problems
|
|
47
|
+
ambiguous_local_time 2 local time happens twice (clocks went back)
|
|
48
|
+
line 19 PT-101 = 8.07 at 2026-10-25 02:00:01
|
|
49
|
+
line 20 FT-102 = 42.0 at 2026-10-25 02:00:01
|
|
50
|
+
gap_exceeds_limit 2 gap since the previous value exceeds max_gap_seconds
|
|
51
|
+
line 17 PT-101 = 8.06 at 2026-10-25 01:59:58
|
|
52
|
+
line 18 FT-102 = 41.9 at 2026-10-25 01:59:58
|
|
53
|
+
duplicate_timestamp 1 same tag twice at the same time
|
|
54
|
+
line 12 PT-101 = 8.04 at 2026-10-25 01:59:44
|
|
55
|
+
nonfinite_or_nonnumeric_value 1 value is not a number
|
|
56
|
+
line 9 FT-102 = I/O Timeout at 2026-10-25 01:59:43
|
|
57
|
+
outside_engineering_range 1 value outside the declared range
|
|
58
|
+
line 6 PT-101 = 803 at 2026-10-25 01:59:42
|
|
59
|
+
quality_bad 1 quality code says bad
|
|
60
|
+
line 9 FT-102 = I/O Timeout at 2026-10-25 01:59:43
|
|
61
|
+
quality_uncertain 1 quality code says uncertain
|
|
62
|
+
line 11 FT-102 = 41.8 at 2026-10-25 01:59:44
|
|
63
|
+
stuck_value 1 value unchanged for more than max_repeats samples
|
|
64
|
+
line 16 FT-102 = 41.8 at 2026-10-25 01:59:48
|
|
65
|
+
timestamp_went_backwards 1 earlier than this tag's previous value
|
|
66
|
+
line 21 PT-101 = 8.06 at 2026-10-25 01:59:50
|
|
67
|
+
unit_mismatch 1 unit differs from the profile
|
|
68
|
+
line 6 PT-101 = 803 at 2026-10-25 01:59:42
|
|
69
|
+
|
|
70
|
+
Not checked
|
|
71
|
+
freshness exports carry no receive time, so data age at the edge is unknown
|
|
72
|
+
sample_groups long export is not declared synchronized
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Exit codes: `0` all checks passed, `2` problems found, `1` the file or profile couldn't be
|
|
76
|
+
read. Add `--output report.json` for a JSON report, or `--json` to print it.
|
|
77
|
+
|
|
78
|
+
## What it reads
|
|
79
|
+
|
|
80
|
+
| Layout | Looks like | Notes |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| Long | `Timestamp,TagName,Value,Quality,Units` | One value per row. Quality and unit columns are optional. |
|
|
83
|
+
| Wide | `Timestamp,PT-101,FT-102` | One column per tag. A blank cell counts as a missing value in that row. |
|
|
84
|
+
| Native capture | written by `tagaudit collect` | Adds OPC UA source, server and receive timestamps, so freshness can be checked. |
|
|
85
|
+
|
|
86
|
+
For wide and synchronized long exports, the report also counts missing values per tag and
|
|
87
|
+
names the tags that are empty in every row.
|
|
88
|
+
|
|
89
|
+
Each file needs one column holding the full date and time. Exports that split date and time
|
|
90
|
+
across several columns aren't supported yet. Timestamps can be ISO 8601 with or without a UTC
|
|
91
|
+
offset, epoch seconds or milliseconds, or any `strptime` pattern. If they have no offset, set `input.timezone` (`UTC`, `+04:00` or a zone
|
|
92
|
+
such as `Europe/Berlin`). With a named zone, `tagaudit` flags times that occur twice or never
|
|
93
|
+
during clock changes.
|
|
94
|
+
|
|
95
|
+
## Profiles
|
|
96
|
+
|
|
97
|
+
A profile says what the data should look like. `tagaudit init` writes the layout, tags and
|
|
98
|
+
units it finds. It leaves the rest for you, because guessing them would make those checks
|
|
99
|
+
meaningless.
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"schema": "tagaudit.profile.v1",
|
|
104
|
+
"quality_encoding": "opc_da_quality",
|
|
105
|
+
"max_gap_seconds": 5,
|
|
106
|
+
"max_repeats": 3,
|
|
107
|
+
"input": {"format": "long", "timestamp": "Timestamp", "tag": "TagName", "value": "Value",
|
|
108
|
+
"quality": "Quality", "unit": "Units", "timezone": "Europe/Berlin"},
|
|
109
|
+
"tags": [
|
|
110
|
+
{"name": "PT-101", "unit": "bar", "minimum": 0, "maximum": 16},
|
|
111
|
+
{"name": "FT-102", "unit": "m3/h", "minimum": 0, "maximum": 120, "max_gap_seconds": 10}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `quality_encoding`: `opcua_status_code` (0 is good), `opc_da_quality` (192 is good, 0 is
|
|
117
|
+
bad) or `quality_words` (`good`, `uncertain`, `bad`). The two numeric schemes read 0 in
|
|
118
|
+
opposite ways, so `tagaudit` never guesses.
|
|
119
|
+
- `minimum` and `maximum`: either or both. Tags without them are listed under "Not checked".
|
|
120
|
+
- `max_gap_seconds`: the longest silence allowed between values of a tag.
|
|
121
|
+
- `max_repeats`: how many times in a row a value may repeat before it counts as stuck.
|
|
122
|
+
Per-tag values override the profile-wide ones.
|
|
123
|
+
- Wide exports map tag names to columns with `"input": {"format": "wide", "columns": {"PT-101": "Pump01/Pressure"}}`.
|
|
124
|
+
|
|
125
|
+
## OPC UA captures
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
pip install "tagaudit[opcua]"
|
|
129
|
+
tagaudit collect --profile capture-profile.json --endpoint opc.tcp://192.168.0.10:4840 \
|
|
130
|
+
--certificate client.pem --private-key client-key.pem --server-certificate server.der \
|
|
131
|
+
--csv capture.csv --output capture.audit.json
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The collector only reads: it exposes no Write or Call service, and it takes a bounded number
|
|
135
|
+
of samples (`--samples`, default 5). It records each value's source, server and receive
|
|
136
|
+
timestamps, so the audit can tell a fresh server timestamp on an old value from genuinely new
|
|
137
|
+
data. Use a server-side read-only role as well, because client code is not access control.
|
|
138
|
+
[`examples/capture-faults.csv`](https://github.com/sankalpsthakur/tagaudit/blob/main/examples/capture-faults.csv) shows the checks on a capture.
|
|
139
|
+
|
|
140
|
+
For machines without `pip`, copy `audit.py` out of the repository or the wheel. It runs on
|
|
141
|
+
its own with the standard library and checks native captures:
|
|
142
|
+
`python audit.py --profile profile.json --csv capture.csv --output report.json`.
|
|
143
|
+
|
|
144
|
+
## What a pass does not mean
|
|
145
|
+
|
|
146
|
+
A pass means the file matches its profile. It doesn't show that sensors are calibrated, that
|
|
147
|
+
the source was authentic, that an export is still current, or that a model trained on the data
|
|
148
|
+
will behave. Checks the file can't support are listed under "Not checked" instead of being
|
|
149
|
+
skipped silently.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache-2.0. Copyright 2026 Sankalp Thakur.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tagaudit"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Check industrial tag data before you trust it: units, ranges, quality codes, timestamps, gaps and stuck values in OPC UA captures and historian CSV exports."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "Apache-2.0"}
|
|
12
|
+
authors = [{name = "Sankalp Thakur"}]
|
|
13
|
+
keywords = ["opc-ua", "historian", "scada", "data-quality", "iiot", "telemetry", "industrial", "time-series"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Manufacturing",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"License :: OSI Approved :: Apache Software License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Topic :: Scientific/Engineering",
|
|
24
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
25
|
+
]
|
|
26
|
+
# Standard library only, except the IANA time zone database, which Windows doesn't ship.
|
|
27
|
+
dependencies = ['tzdata; sys_platform == "win32"']
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
# The collector decodes OPC UA Read responses itself (see opcua.py), so it is
|
|
31
|
+
# pinned to the asyncua release whose wire helpers it was tested against.
|
|
32
|
+
opcua = ["asyncua==2.0.1"]
|
|
33
|
+
test = ["pytest>=8"]
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
tagaudit = "tagaudit.cli:main"
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/sankalpsthakur/tagaudit"
|
|
40
|
+
Issues = "https://github.com/sankalpsthakur/tagaudit/issues"
|
|
41
|
+
Changelog = "https://github.com/sankalpsthakur/tagaudit/blob/main/CHANGELOG.md"
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.packages.find]
|
|
44
|
+
where = ["src"]
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = ["tests"]
|
tagaudit-0.1.1/setup.cfg
ADDED