inception-reports 0.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.
- inception_reports-0.1/LICENSE +202 -0
- inception_reports-0.1/NOTICE.txt +15 -0
- inception_reports-0.1/PKG-INFO +40 -0
- inception_reports-0.1/README.md +20 -0
- inception_reports-0.1/inception_reports/__init__.py +15 -0
- inception_reports-0.1/inception_reports/__main__.py +47 -0
- inception_reports-0.1/inception_reports/generate_reports_lead.py +231 -0
- inception_reports-0.1/inception_reports/generate_reports_manager.py +373 -0
- inception_reports-0.1/inception_reports.egg-info/PKG-INFO +40 -0
- inception_reports-0.1/inception_reports.egg-info/SOURCES.txt +16 -0
- inception_reports-0.1/inception_reports.egg-info/dependency_links.txt +1 -0
- inception_reports-0.1/inception_reports.egg-info/entry_points.txt +2 -0
- inception_reports-0.1/inception_reports.egg-info/requires.txt +6 -0
- inception_reports-0.1/inception_reports.egg-info/top_level.txt +1 -0
- inception_reports-0.1/pyproject.toml +33 -0
- inception_reports-0.1/setup.cfg +4 -0
- inception_reports-0.1/tests/test_generate_reports_lead.py +111 -0
- inception_reports-0.1/tests/test_generate_reports_manager.py +75 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
The copyright of the code in this repository belongs to the respective contributors who
|
|
2
|
+
license their contribution under the terms of the Apache License 2.0.
|
|
3
|
+
|
|
4
|
+
Besides individual contributions, the copyright in this codebase largely belongs to:
|
|
5
|
+
|
|
6
|
+
Copyright 2018-2021 Ubiquitous Knowledge Processing (UKP) Lab
|
|
7
|
+
Technische Universität Darmstadt
|
|
8
|
+
(in the context of the INCEpTION project)
|
|
9
|
+
|
|
10
|
+
Copyright 2012-2016 Ubiquitous Knowledge Processing (UKP) Lab and FG Language Technology
|
|
11
|
+
Technische Universität Darmstadt
|
|
12
|
+
(in the context of the WebAnno project(s))
|
|
13
|
+
|
|
14
|
+
For individual contributions, please check the CONTRIBITORS.txt file as well as the history
|
|
15
|
+
contained in this repository.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: inception_reports
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Generate plots that report the progress of an INCEpTION project.
|
|
5
|
+
Author-email: Serwar Basch <serwar.basch@tu-darmstadt.de>
|
|
6
|
+
Project-URL: Homepage, https://github.com/inception-project/inception-reporting-dashboard
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
License-File: NOTICE.txt
|
|
14
|
+
Requires-Dist: streamlit
|
|
15
|
+
Requires-Dist: pandas
|
|
16
|
+
Requires-Dist: matplotlib
|
|
17
|
+
Requires-Dist: numpy
|
|
18
|
+
Requires-Dist: dkpro-cassis
|
|
19
|
+
Requires-Dist: pycaprio
|
|
20
|
+
|
|
21
|
+
# INCEpTION Reporting Dashboard
|
|
22
|
+
|
|
23
|
+
This package will generate plots to track the progress of your INCEpTION project(s).
|
|
24
|
+
|
|
25
|
+
In its current state, it can be used by the project manager on site to visualize different metrics regarding the progress of the project, and the type of annotations done.
|
|
26
|
+
|
|
27
|
+
In case the project is part of a bigger project, the project progress can be exported to be sent to a project lead in a centralized location who, in turn, can use the package to get an overview of the progress across the different projects and locations.
|
|
28
|
+
|
|
29
|
+
## Getting started
|
|
30
|
+
|
|
31
|
+
1. Ensure you have python 3.11 or higher (check it using python --version)
|
|
32
|
+
2. Install the package using ``pip install inception_reports``
|
|
33
|
+
3. Run the script using ``inception_reports --help`` this will show you the options you have:
|
|
34
|
+
1. Run it with ``inception_reports --manager`` if you have one python project, or are responsible for one location.
|
|
35
|
+
2. Run it with ``inception_reports --lead`` if you're leading multiple projects, or multiple locations.
|
|
36
|
+
4. Regardless of the mode you run the package with, it should open a browser window. Follow the instructions on the page to proceed.
|
|
37
|
+
|
|
38
|
+
## Issues
|
|
39
|
+
|
|
40
|
+
This package is under early developments, if you notice any bugs, or face any issues, do not hesitate to open a [Github issue](https://github.com/inception-project/inception-reporting-dashboard/issues).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# INCEpTION Reporting Dashboard
|
|
2
|
+
|
|
3
|
+
This package will generate plots to track the progress of your INCEpTION project(s).
|
|
4
|
+
|
|
5
|
+
In its current state, it can be used by the project manager on site to visualize different metrics regarding the progress of the project, and the type of annotations done.
|
|
6
|
+
|
|
7
|
+
In case the project is part of a bigger project, the project progress can be exported to be sent to a project lead in a centralized location who, in turn, can use the package to get an overview of the progress across the different projects and locations.
|
|
8
|
+
|
|
9
|
+
## Getting started
|
|
10
|
+
|
|
11
|
+
1. Ensure you have python 3.11 or higher (check it using python --version)
|
|
12
|
+
2. Install the package using ``pip install inception_reports``
|
|
13
|
+
3. Run the script using ``inception_reports --help`` this will show you the options you have:
|
|
14
|
+
1. Run it with ``inception_reports --manager`` if you have one python project, or are responsible for one location.
|
|
15
|
+
2. Run it with ``inception_reports --lead`` if you're leading multiple projects, or multiple locations.
|
|
16
|
+
4. Regardless of the mode you run the package with, it should open a browser window. Follow the instructions on the page to proceed.
|
|
17
|
+
|
|
18
|
+
## Issues
|
|
19
|
+
|
|
20
|
+
This package is under early developments, if you notice any bugs, or face any issues, do not hesitate to open a [Github issue](https://github.com/inception-project/inception-reporting-dashboard/issues).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Licensed to the Technische Universität Darmstadt under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The Technische Universität Darmstadt
|
|
5
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License.
|
|
8
|
+
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Licensed to the Technische Universität Darmstadt under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The Technische Universität Darmstadt
|
|
5
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License.
|
|
8
|
+
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import sys
|
|
19
|
+
import argparse
|
|
20
|
+
from streamlit.web import cli
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def main():
|
|
24
|
+
parser = argparse.ArgumentParser(
|
|
25
|
+
description="Generate plots for your INCEpTION project."
|
|
26
|
+
)
|
|
27
|
+
group = parser.add_mutually_exclusive_group(required=True)
|
|
28
|
+
group.add_argument(
|
|
29
|
+
"--manager", help="You are managing a single project, or a single location.", action="store_true"
|
|
30
|
+
)
|
|
31
|
+
group.add_argument("--lead", help="You are leading multiple projects, or multiple locations.", action="store_true")
|
|
32
|
+
|
|
33
|
+
args = parser.parse_args()
|
|
34
|
+
|
|
35
|
+
if args.manager:
|
|
36
|
+
sys.argv = [
|
|
37
|
+
"streamlit",
|
|
38
|
+
"run",
|
|
39
|
+
f"{os.path.dirname(os.path.realpath(__file__))}/generate_reports_manager.py",
|
|
40
|
+
]
|
|
41
|
+
elif args.lead:
|
|
42
|
+
sys.argv = [
|
|
43
|
+
"streamlit",
|
|
44
|
+
"run",
|
|
45
|
+
f"{os.path.dirname(os.path.realpath(__file__))}/generate_reports_lead.py",
|
|
46
|
+
]
|
|
47
|
+
sys.exit(cli.main())
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Licensed to the Technische Universität Darmstadt under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The Technische Universität Darmstadt
|
|
5
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License.
|
|
8
|
+
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import os
|
|
19
|
+
import warnings
|
|
20
|
+
|
|
21
|
+
import matplotlib.pyplot as plt
|
|
22
|
+
import numpy as np
|
|
23
|
+
import streamlit as st
|
|
24
|
+
|
|
25
|
+
# suppress deprecation warnings related to the use of the pyplot
|
|
26
|
+
# can be solved by sending the fig instead of the plt to streamlit
|
|
27
|
+
st.set_option("deprecation.showPyplotGlobalUse", False)
|
|
28
|
+
st.set_page_config(page_title="INCEpTION Reporting Dashboard", layout="centered")
|
|
29
|
+
warnings.filterwarnings("ignore", message="Boolean Series key will be reindexed to match DataFrame index")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def change_width(page_width=80) -> None:
|
|
33
|
+
css=f'''
|
|
34
|
+
<style>
|
|
35
|
+
section.main > div {{max-width:{page_width}%}}
|
|
36
|
+
</style>
|
|
37
|
+
'''
|
|
38
|
+
st.markdown(css, unsafe_allow_html=True)
|
|
39
|
+
|
|
40
|
+
def plot_multiples(projects, tag) -> None:
|
|
41
|
+
|
|
42
|
+
st.title(f"Projects with tag: {tag}")
|
|
43
|
+
plt.figure(figsize=(30, 6), dpi=800)
|
|
44
|
+
|
|
45
|
+
pie_labels = [
|
|
46
|
+
"New",
|
|
47
|
+
"Annotation In Progress",
|
|
48
|
+
"Annotation Finished",
|
|
49
|
+
"Curation In Progress",
|
|
50
|
+
"Curation Finished",
|
|
51
|
+
]
|
|
52
|
+
pie_colors = [
|
|
53
|
+
'tab:red',
|
|
54
|
+
'cornflowerblue',
|
|
55
|
+
'royalblue',
|
|
56
|
+
'limegreen',
|
|
57
|
+
'forestgreen',
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
for idx, project in enumerate(projects):
|
|
61
|
+
plt.subplot(1, len(projects), idx+1)
|
|
62
|
+
plt.title(project["project_name"].split(".")[0], fontsize=22, fontweight="bold")
|
|
63
|
+
data_sizes = [
|
|
64
|
+
project["doc_categories"]["NEW"],
|
|
65
|
+
project["doc_categories"]["ANNOTATION_IN_PROGRESS"],
|
|
66
|
+
project["doc_categories"]["ANNOTATION_FINISHED"],
|
|
67
|
+
project["doc_categories"]["CURATION_IN_PROGRESS"],
|
|
68
|
+
project["doc_categories"]["CURATION_FINISHED"],
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
pie_percentages = 100.0 * np.array(data_sizes) / np.array(data_sizes).sum()
|
|
72
|
+
|
|
73
|
+
wedges, _ = plt.pie(
|
|
74
|
+
data_sizes,
|
|
75
|
+
colors=pie_colors,
|
|
76
|
+
startangle=90,
|
|
77
|
+
radius=2,
|
|
78
|
+
counterclock=False
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
plt.axis("equal")
|
|
82
|
+
|
|
83
|
+
legend_labels = [
|
|
84
|
+
f"{label} ({percent:.2f}% / {size} files)"
|
|
85
|
+
for label, size, percent in zip(pie_labels, data_sizes, pie_percentages)
|
|
86
|
+
]
|
|
87
|
+
plt.legend(
|
|
88
|
+
wedges,
|
|
89
|
+
legend_labels,
|
|
90
|
+
title="Categories",
|
|
91
|
+
fontsize=12,
|
|
92
|
+
loc="center left",
|
|
93
|
+
bbox_to_anchor=(1, 0.5),
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
plt.tight_layout()
|
|
97
|
+
st.pyplot()
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def plot_project_progress(project_data, multiple=False) -> None:
|
|
101
|
+
"""
|
|
102
|
+
Generate a visual representation of project progress based on an export of project details provided by the site manager.
|
|
103
|
+
|
|
104
|
+
This function takes a dict containing project progress data and generates a pie chart showing the percentage of files finished vs. remaining.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
Parameters:
|
|
108
|
+
project_data (dict): A dictionary containing project progress data.
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
st.title(f"Project: {project_data['project_name'].split('.')[0]}")
|
|
112
|
+
|
|
113
|
+
data_sizes = [
|
|
114
|
+
project_data["doc_categories"]["NEW"],
|
|
115
|
+
project_data["doc_categories"]["ANNOTATION_IN_PROGRESS"],
|
|
116
|
+
project_data["doc_categories"]["ANNOTATION_FINISHED"],
|
|
117
|
+
project_data["doc_categories"]["CURATION_IN_PROGRESS"],
|
|
118
|
+
project_data["doc_categories"]["CURATION_FINISHED"],
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
pie_labels = [
|
|
122
|
+
"New",
|
|
123
|
+
"Annotation In Progress",
|
|
124
|
+
"Annotation Finished",
|
|
125
|
+
"Curation In Progress",
|
|
126
|
+
"Curation Finished",
|
|
127
|
+
]
|
|
128
|
+
pie_colors = [
|
|
129
|
+
"#fc1c03",
|
|
130
|
+
"#fcbe03",
|
|
131
|
+
"#03fc17",
|
|
132
|
+
"#0373fc",
|
|
133
|
+
"#4e03fc",
|
|
134
|
+
]
|
|
135
|
+
pie_percentages = 100.0 * np.array(data_sizes) / np.array(data_sizes).sum()
|
|
136
|
+
plt.figure(figsize=(15, 9))
|
|
137
|
+
plt.suptitle(f"Documents' Status\n{project_data['project_tags'][-1].upper()}", fontsize=16, fontweight="bold")
|
|
138
|
+
wedges, texts = plt.pie(
|
|
139
|
+
data_sizes,
|
|
140
|
+
colors=pie_colors,
|
|
141
|
+
startangle=140)
|
|
142
|
+
|
|
143
|
+
plt.axis("equal")
|
|
144
|
+
|
|
145
|
+
# Create a legend with labels and percentages
|
|
146
|
+
legend_labels = [
|
|
147
|
+
f"{label} ({percent:.2f}% / {size} files)"
|
|
148
|
+
for label, size, percent in zip(pie_labels, data_sizes, pie_percentages)
|
|
149
|
+
]
|
|
150
|
+
plt.legend(
|
|
151
|
+
wedges,
|
|
152
|
+
legend_labels,
|
|
153
|
+
title="Categories",
|
|
154
|
+
fontsize=12,
|
|
155
|
+
loc="center left",
|
|
156
|
+
bbox_to_anchor=(1, 0.5),
|
|
157
|
+
)
|
|
158
|
+
plt.tight_layout()
|
|
159
|
+
st.pyplot()
|
|
160
|
+
|
|
161
|
+
def read_dir(dir) -> list[dict]:
|
|
162
|
+
"""
|
|
163
|
+
Read a file and return a pandas dataframe, regardless of the file type.
|
|
164
|
+
|
|
165
|
+
Parameters:
|
|
166
|
+
dir (str): The dir of INCEpTION projects progress data.
|
|
167
|
+
|
|
168
|
+
Returns
|
|
169
|
+
List[dict]: A list of dicts containing the project progress data as json files.
|
|
170
|
+
"""
|
|
171
|
+
projects = []
|
|
172
|
+
|
|
173
|
+
for file in os.listdir(dir):
|
|
174
|
+
projects.append(json.load(open(os.path.join(dir, file), "r")))
|
|
175
|
+
return projects
|
|
176
|
+
|
|
177
|
+
def get_unique_tags(projects):
|
|
178
|
+
"""
|
|
179
|
+
Get a list of unique tags from a list of projects.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
projects (list): A list of projects.
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
list: A list of unique tags extracted from the projects.
|
|
186
|
+
"""
|
|
187
|
+
unique_tags = set()
|
|
188
|
+
for project in projects:
|
|
189
|
+
unique_tags.update(project.get('project_tags', []))
|
|
190
|
+
return list(unique_tags)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def select_data_folder():
|
|
194
|
+
"""
|
|
195
|
+
Generate a sidebar widget to select the data folder containing the INCEpTION projects.
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
st.sidebar.write("Please input the path to the folder containing the INCEpTION projects.")
|
|
199
|
+
projects_folder = st.sidebar.text_input("Projects Folder:", value="")
|
|
200
|
+
if st.sidebar.button("Generate Reports"):
|
|
201
|
+
st.session_state['initialized'] = True
|
|
202
|
+
st.session_state['projects_folder'] = projects_folder
|
|
203
|
+
|
|
204
|
+
def main():
|
|
205
|
+
change_width(80)
|
|
206
|
+
st.title("INCEpTION Projects Progress")
|
|
207
|
+
|
|
208
|
+
select_data_folder()
|
|
209
|
+
|
|
210
|
+
projects = []
|
|
211
|
+
if 'projects_folder' in st.session_state:
|
|
212
|
+
projects = read_dir(st.session_state.projects_folder)
|
|
213
|
+
projects.sort(key=lambda x: x["project_name"])
|
|
214
|
+
|
|
215
|
+
if projects:
|
|
216
|
+
unique_tags = get_unique_tags(projects)
|
|
217
|
+
|
|
218
|
+
selected_tags = []
|
|
219
|
+
columns = st.columns(len(unique_tags))
|
|
220
|
+
|
|
221
|
+
for col, tag in zip(columns, unique_tags):
|
|
222
|
+
if col.checkbox(tag.capitalize(), key=tag):
|
|
223
|
+
selected_tags.append(tag)
|
|
224
|
+
|
|
225
|
+
for tag in selected_tags:
|
|
226
|
+
multi_projects = [project for project in projects if tag in project["project_tags"]]
|
|
227
|
+
plot_multiples(multi_projects, tag)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
if __name__ == "__main__":
|
|
231
|
+
main()
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# Licensed to the Technische Universität Darmstadt under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The Technische Universität Darmstadt
|
|
5
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License.
|
|
8
|
+
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import os
|
|
19
|
+
import shutil
|
|
20
|
+
import warnings
|
|
21
|
+
import zipfile
|
|
22
|
+
|
|
23
|
+
import cassis
|
|
24
|
+
import matplotlib.pyplot as plt
|
|
25
|
+
import numpy as np
|
|
26
|
+
import streamlit as st
|
|
27
|
+
from matplotlib import gridspec
|
|
28
|
+
from pycaprio import Pycaprio
|
|
29
|
+
|
|
30
|
+
# suppress deprecation warnings related to the use of the pyplot
|
|
31
|
+
# can be solved by sending the fig instead of the plt to streamlit
|
|
32
|
+
st.set_option("deprecation.showPyplotGlobalUse", False)
|
|
33
|
+
st.set_page_config(page_title="INCEpTION Reporting Dashboard", layout="centered")
|
|
34
|
+
css = """
|
|
35
|
+
<style>
|
|
36
|
+
section.main > div {max-width:50%}
|
|
37
|
+
</style>
|
|
38
|
+
"""
|
|
39
|
+
st.markdown(css, unsafe_allow_html=True)
|
|
40
|
+
warnings.filterwarnings(
|
|
41
|
+
"ignore", message="Boolean Series key will be reindexed to match DataFrame index"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def plot_project_progress(project) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Generate a visual representation of project progress based on a DataFrame of log data.
|
|
48
|
+
|
|
49
|
+
This function takes a DataFrame containing log data and generates
|
|
50
|
+
visualizations to represent the progress of different documents. It calculates the
|
|
51
|
+
total time spent on each document, divides it into sessions based on a specified
|
|
52
|
+
threshold, and displays a pie chart showing the percentage of finished and remaining
|
|
53
|
+
documents, along with a bar chart showing the total time spent on finished documents
|
|
54
|
+
compared to the estimated time for remaining documents.
|
|
55
|
+
|
|
56
|
+
Parameters:
|
|
57
|
+
project (dict): A dict containing project information, namely the name, tags, annotations, and logs.
|
|
58
|
+
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
# df = project["logs"]
|
|
62
|
+
project_name = project["name"]
|
|
63
|
+
project_tags = project["tags"]
|
|
64
|
+
project_annotations = project["annotations"]
|
|
65
|
+
project_documents = project["documents"]
|
|
66
|
+
|
|
67
|
+
doc_categories = {
|
|
68
|
+
"ANNOTATION_IN_PROGRESS": 0,
|
|
69
|
+
"ANNOTATION_FINISHED": 0,
|
|
70
|
+
"CURATION_IN_PROGRESS": 0,
|
|
71
|
+
"CURATION_FINISHED": 0,
|
|
72
|
+
"NEW": 0,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
for doc in project_documents:
|
|
76
|
+
state = doc["state"]
|
|
77
|
+
if state in doc_categories:
|
|
78
|
+
doc_categories[state] += 1
|
|
79
|
+
|
|
80
|
+
project_data = {
|
|
81
|
+
"project_name": project_name,
|
|
82
|
+
"project_tags": project_tags,
|
|
83
|
+
"doc_categories": doc_categories,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
type_counts = get_type_counts(project_annotations)
|
|
89
|
+
selected_annotation_types = st.multiselect(
|
|
90
|
+
f"Which annotation types would you like to see for {project_name}?",
|
|
91
|
+
list(type_counts.keys()),
|
|
92
|
+
list(type_counts.keys())
|
|
93
|
+
)
|
|
94
|
+
type_counts = {k: v for k, v in type_counts.items() if k in selected_annotation_types}
|
|
95
|
+
|
|
96
|
+
data_sizes = [
|
|
97
|
+
project_data["doc_categories"]["NEW"],
|
|
98
|
+
project_data["doc_categories"]["ANNOTATION_IN_PROGRESS"],
|
|
99
|
+
project_data["doc_categories"]["ANNOTATION_FINISHED"],
|
|
100
|
+
project_data["doc_categories"]["CURATION_IN_PROGRESS"],
|
|
101
|
+
project_data["doc_categories"]["CURATION_FINISHED"],
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
pie_labels = [
|
|
105
|
+
"New",
|
|
106
|
+
"Annotation In Progress",
|
|
107
|
+
"Annotation Finished",
|
|
108
|
+
"Curation In Progress",
|
|
109
|
+
"Curation Finished",
|
|
110
|
+
]
|
|
111
|
+
pie_colors = [
|
|
112
|
+
"tab:red",
|
|
113
|
+
"cornflowerblue",
|
|
114
|
+
"royalblue",
|
|
115
|
+
"limegreen",
|
|
116
|
+
"forestgreen",
|
|
117
|
+
]
|
|
118
|
+
pie_percentages = 100.0 * np.array(data_sizes) / np.array(data_sizes).sum()
|
|
119
|
+
fig = plt.figure(figsize=(15, 9))
|
|
120
|
+
gs = gridspec.GridSpec(1, 3, width_ratios=[1, 0.01, 1])
|
|
121
|
+
|
|
122
|
+
ax1 = plt.subplot(gs[0])
|
|
123
|
+
|
|
124
|
+
wedges, _ = ax1.pie(
|
|
125
|
+
data_sizes, colors=pie_colors, startangle=90, radius=2, counterclock=False
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
ax1.axis("equal")
|
|
129
|
+
total_annotations = sum(
|
|
130
|
+
[len(cas_file.select_all()) for cas_file in project_annotations.values()]
|
|
131
|
+
)
|
|
132
|
+
ax1.set_title("Documents Status")
|
|
133
|
+
|
|
134
|
+
legend_labels = [
|
|
135
|
+
f"{label} ({percent:.2f}% / {size} files)"
|
|
136
|
+
for label, size, percent in zip(pie_labels, data_sizes, pie_percentages)
|
|
137
|
+
]
|
|
138
|
+
ax1.legend(
|
|
139
|
+
wedges,
|
|
140
|
+
legend_labels,
|
|
141
|
+
title="Categories",
|
|
142
|
+
loc="center left",
|
|
143
|
+
bbox_to_anchor=(1, 0.5),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
ax2 = plt.subplot(gs[2])
|
|
147
|
+
colors = plt.cm.tab10(range(len(type_counts.keys())))
|
|
148
|
+
ax2.set_title("Types of Annotations")
|
|
149
|
+
ax2.barh(
|
|
150
|
+
[f"{type} = {value}" for type, value in type_counts.items()],
|
|
151
|
+
list(type_counts.values()),
|
|
152
|
+
color=colors,
|
|
153
|
+
)
|
|
154
|
+
ax2.set_xlabel("Number of Annotations")
|
|
155
|
+
|
|
156
|
+
fig.suptitle(
|
|
157
|
+
f'{project_name.split(".")[0]}\nTotal Annotations: {total_annotations}',
|
|
158
|
+
fontsize=16,
|
|
159
|
+
)
|
|
160
|
+
fig.tight_layout()
|
|
161
|
+
st.pyplot()
|
|
162
|
+
|
|
163
|
+
# st.title(f"Project: {project_name.split('.')[0]}")
|
|
164
|
+
if st.button(f"Export data for {project_name.split('.')[0]}"):
|
|
165
|
+
with open(f"{project_name.split('.')[0]}_data.json", "w") as output_file:
|
|
166
|
+
output_file.write(json.dumps(project_data, indent=4))
|
|
167
|
+
st.success(f"{project_name.split('.')[0]} data exported successfully ✅")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def find_element_by_name(element_list, name):
|
|
171
|
+
"""
|
|
172
|
+
Finds an element in the given element list by its name.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
element_list (list): A list of elements to search through.
|
|
176
|
+
name (str): The name of the element to find.
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
str: The UI name of the found element, or the last part of the name if not found.
|
|
180
|
+
"""
|
|
181
|
+
for element in element_list:
|
|
182
|
+
if element.name == name:
|
|
183
|
+
return element.uiName
|
|
184
|
+
return name.split(".")[-1]
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def get_type_counts(annotations):
|
|
188
|
+
"""
|
|
189
|
+
Calculate the count of each type in the given annotations. Each annotation is a CAS object.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
annotations (dict): A dictionary containing the annotations.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
dict: A dictionary containing the count of each type.
|
|
196
|
+
"""
|
|
197
|
+
count_dict = {}
|
|
198
|
+
|
|
199
|
+
layerDefinition = annotations.popitem()[1].select(
|
|
200
|
+
"de.tudarmstadt.ukp.clarin.webanno.api.type.LayerDefinition"
|
|
201
|
+
)
|
|
202
|
+
for doc in annotations:
|
|
203
|
+
type_names = [
|
|
204
|
+
(
|
|
205
|
+
find_element_by_name(layerDefinition, t.name),
|
|
206
|
+
len(annotations[doc].select(t.name)),
|
|
207
|
+
)
|
|
208
|
+
for t in annotations[doc].typesystem.get_types()
|
|
209
|
+
if t.name != "de.tudarmstadt.ukp.clarin.webanno.api.type.LayerDefinition"
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
for type_name, count in type_names:
|
|
213
|
+
if type_name not in count_dict:
|
|
214
|
+
count_dict[type_name] = 0
|
|
215
|
+
count_dict[type_name] += count
|
|
216
|
+
count_dict = {k: v for k, v in count_dict.items() if v > 0}
|
|
217
|
+
count_dict = dict(sorted(count_dict.items(), key=lambda item: item[1]))
|
|
218
|
+
|
|
219
|
+
return count_dict
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def read_dir(dir_path: str) -> list[dict]:
|
|
223
|
+
"""
|
|
224
|
+
Reads a directory containing zip files, extracts the contents, and retrieves project metadata and annotations.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
dir_path (str): The path to the directory containing the zip files.
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
list[dict]: A list of dictionaries, where each dictionary represents a project and contains the following keys:
|
|
231
|
+
- "name": The name of the zip file.
|
|
232
|
+
- "tags": A list of tags extracted from the project metadata.
|
|
233
|
+
- "documents": A list of source documents from the project metadata.
|
|
234
|
+
- "annotations": A dictionary mapping annotation subfolder names to their corresponding CAS objects.
|
|
235
|
+
"""
|
|
236
|
+
projects = []
|
|
237
|
+
|
|
238
|
+
for file_name in os.listdir(dir_path):
|
|
239
|
+
file_path = os.path.join(dir_path, file_name)
|
|
240
|
+
if zipfile.is_zipfile(file_path):
|
|
241
|
+
with zipfile.ZipFile(file_path, "r") as zip_file:
|
|
242
|
+
zip_path = f"{dir_path}/{file_name.split('.')[0]}"
|
|
243
|
+
zip_file.extractall(path=zip_path)
|
|
244
|
+
|
|
245
|
+
# Find project metadata file
|
|
246
|
+
project_meta_path = os.path.join(zip_path, "exportedproject.json")
|
|
247
|
+
if os.path.exists(project_meta_path):
|
|
248
|
+
with open(project_meta_path, "r") as project_meta_file:
|
|
249
|
+
project_meta = json.load(project_meta_file)
|
|
250
|
+
project_tags = [
|
|
251
|
+
word.strip("#")
|
|
252
|
+
for word in project_meta["description"].split()
|
|
253
|
+
if word.startswith("#")
|
|
254
|
+
]
|
|
255
|
+
project_documents = project_meta["source_documents"]
|
|
256
|
+
|
|
257
|
+
annotations = {}
|
|
258
|
+
# Find annotation folders
|
|
259
|
+
annotation_folders = [
|
|
260
|
+
name
|
|
261
|
+
for name in zip_file.namelist()
|
|
262
|
+
if name.startswith("annotation/")
|
|
263
|
+
and name.endswith(".json")
|
|
264
|
+
and not name.endswith("INITIAL_CAS.json")
|
|
265
|
+
]
|
|
266
|
+
for annotation_file in annotation_folders:
|
|
267
|
+
subfolder_name = os.path.dirname(annotation_file).split("/")[1]
|
|
268
|
+
with zip_file.open(annotation_file) as cas_file:
|
|
269
|
+
cas = cassis.load_cas_from_json(cas_file)
|
|
270
|
+
annotations[subfolder_name] = cas
|
|
271
|
+
|
|
272
|
+
projects.append(
|
|
273
|
+
{
|
|
274
|
+
"name": file_name,
|
|
275
|
+
"tags": project_tags,
|
|
276
|
+
"documents": project_documents,
|
|
277
|
+
"annotations": annotations,
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
# Clean up extracted files
|
|
282
|
+
shutil.rmtree(zip_path)
|
|
283
|
+
|
|
284
|
+
return projects
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def login_to_inception(api_url, username, password):
|
|
289
|
+
"""
|
|
290
|
+
Logs in to the Inception API using the provided API URL, username, and password.
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
api_url (str): The URL of the Inception API.
|
|
294
|
+
username (str): The username for authentication.
|
|
295
|
+
password (str): The password for authentication.
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
tuple: A tuple containing a boolean value indicating whether the login was successful and an instance of the Inception client.
|
|
299
|
+
|
|
300
|
+
"""
|
|
301
|
+
if "http" not in api_url:
|
|
302
|
+
api_url = f"http://{api_url}"
|
|
303
|
+
if st.sidebar.button("Login"):
|
|
304
|
+
inception_client = Pycaprio(api_url, (username, password))
|
|
305
|
+
st.sidebar.success("Login successful ✅")
|
|
306
|
+
return True, inception_client
|
|
307
|
+
return False, None
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def select_method_to_import_data():
|
|
312
|
+
"""
|
|
313
|
+
Allows the user to select a method to import data for generating reports.
|
|
314
|
+
"""
|
|
315
|
+
|
|
316
|
+
method = st.sidebar.radio("Choose your method to import data:", ('Manually', 'API'), index=0)
|
|
317
|
+
|
|
318
|
+
if method == 'Manually':
|
|
319
|
+
st.sidebar.write("Please input the path to the folder containing the INCEpTION projects.")
|
|
320
|
+
projects_folder = st.sidebar.text_input("Projects Folder:", value="data/dresden_projects/")
|
|
321
|
+
if st.sidebar.button("Generate Reports"):
|
|
322
|
+
st.session_state['initialized'] = True
|
|
323
|
+
st.session_state['method'] = 'Manually'
|
|
324
|
+
st.session_state['projects_folder'] = projects_folder
|
|
325
|
+
elif method == 'API':
|
|
326
|
+
api_url = st.sidebar.text_input("Enter API URL:", "")
|
|
327
|
+
username = st.sidebar.text_input("Username:", "")
|
|
328
|
+
password = st.sidebar.text_input("Password:", type="password", value="")
|
|
329
|
+
inception_status, inception_client = login_to_inception(api_url, username, password)
|
|
330
|
+
if inception_status:
|
|
331
|
+
inception_projects = inception_client.api.projects()
|
|
332
|
+
st.sidebar.write("Following projects got imported:")
|
|
333
|
+
for inception_project in inception_projects:
|
|
334
|
+
st.sidebar.write(inception_project.project_name)
|
|
335
|
+
project_export = inception_client.api.export_project(inception_project, "jsoncas")
|
|
336
|
+
with open(f"{os.path.expanduser('~')}/.inception_reports/projects/{inception_project}.zip", "wb") as f:
|
|
337
|
+
f.write(project_export)
|
|
338
|
+
st.session_state['initialized'] = True
|
|
339
|
+
st.session_state['method'] = 'API'
|
|
340
|
+
st.session_state['projects_folder'] = f"{os.path.expanduser('~')}/.inception_reports/projects"
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def create_directory_in_home():
|
|
345
|
+
"""
|
|
346
|
+
Creates a directory in the user's home directory for storing Inception reports.
|
|
347
|
+
"""
|
|
348
|
+
home_dir = os.path.expanduser("~")
|
|
349
|
+
new_dir_path = os.path.join(home_dir, ".inception_reports")
|
|
350
|
+
try:
|
|
351
|
+
os.makedirs(new_dir_path)
|
|
352
|
+
os.makedirs(os.path.join(new_dir_path, "projects"))
|
|
353
|
+
except FileExistsError:
|
|
354
|
+
pass
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def main():
|
|
358
|
+
create_directory_in_home()
|
|
359
|
+
|
|
360
|
+
st.title("INCEpTION Projects Statistics")
|
|
361
|
+
|
|
362
|
+
if 'initialized' not in st.session_state:
|
|
363
|
+
select_method_to_import_data()
|
|
364
|
+
|
|
365
|
+
if 'method' in st.session_state:
|
|
366
|
+
projects = read_dir(st.session_state.projects_folder)
|
|
367
|
+
projects.sort(key=lambda x: x["name"])
|
|
368
|
+
for project in projects:
|
|
369
|
+
plot_project_progress(project)
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
if __name__ == "__main__":
|
|
373
|
+
main()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: inception_reports
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Generate plots that report the progress of an INCEpTION project.
|
|
5
|
+
Author-email: Serwar Basch <serwar.basch@tu-darmstadt.de>
|
|
6
|
+
Project-URL: Homepage, https://github.com/inception-project/inception-reporting-dashboard
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
License-File: NOTICE.txt
|
|
14
|
+
Requires-Dist: streamlit
|
|
15
|
+
Requires-Dist: pandas
|
|
16
|
+
Requires-Dist: matplotlib
|
|
17
|
+
Requires-Dist: numpy
|
|
18
|
+
Requires-Dist: dkpro-cassis
|
|
19
|
+
Requires-Dist: pycaprio
|
|
20
|
+
|
|
21
|
+
# INCEpTION Reporting Dashboard
|
|
22
|
+
|
|
23
|
+
This package will generate plots to track the progress of your INCEpTION project(s).
|
|
24
|
+
|
|
25
|
+
In its current state, it can be used by the project manager on site to visualize different metrics regarding the progress of the project, and the type of annotations done.
|
|
26
|
+
|
|
27
|
+
In case the project is part of a bigger project, the project progress can be exported to be sent to a project lead in a centralized location who, in turn, can use the package to get an overview of the progress across the different projects and locations.
|
|
28
|
+
|
|
29
|
+
## Getting started
|
|
30
|
+
|
|
31
|
+
1. Ensure you have python 3.11 or higher (check it using python --version)
|
|
32
|
+
2. Install the package using ``pip install inception_reports``
|
|
33
|
+
3. Run the script using ``inception_reports --help`` this will show you the options you have:
|
|
34
|
+
1. Run it with ``inception_reports --manager`` if you have one python project, or are responsible for one location.
|
|
35
|
+
2. Run it with ``inception_reports --lead`` if you're leading multiple projects, or multiple locations.
|
|
36
|
+
4. Regardless of the mode you run the package with, it should open a browser window. Follow the instructions on the page to proceed.
|
|
37
|
+
|
|
38
|
+
## Issues
|
|
39
|
+
|
|
40
|
+
This package is under early developments, if you notice any bugs, or face any issues, do not hesitate to open a [Github issue](https://github.com/inception-project/inception-reporting-dashboard/issues).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
NOTICE.txt
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
inception_reports/__init__.py
|
|
6
|
+
inception_reports/__main__.py
|
|
7
|
+
inception_reports/generate_reports_lead.py
|
|
8
|
+
inception_reports/generate_reports_manager.py
|
|
9
|
+
inception_reports.egg-info/PKG-INFO
|
|
10
|
+
inception_reports.egg-info/SOURCES.txt
|
|
11
|
+
inception_reports.egg-info/dependency_links.txt
|
|
12
|
+
inception_reports.egg-info/entry_points.txt
|
|
13
|
+
inception_reports.egg-info/requires.txt
|
|
14
|
+
inception_reports.egg-info/top_level.txt
|
|
15
|
+
tests/test_generate_reports_lead.py
|
|
16
|
+
tests/test_generate_reports_manager.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
inception_reports
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "inception_reports"
|
|
7
|
+
description = "Generate plots that report the progress of an INCEpTION project."
|
|
8
|
+
version = "0.1"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Serwar Basch", email = "serwar.basch@tu-darmstadt.de" }
|
|
11
|
+
]
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"streamlit",
|
|
16
|
+
"pandas",
|
|
17
|
+
"matplotlib",
|
|
18
|
+
"numpy",
|
|
19
|
+
"dkpro-cassis",
|
|
20
|
+
"pycaprio",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"License :: OSI Approved :: Apache Software License",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
inception_reports = "inception_reports.__main__:main"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/inception-project/inception-reporting-dashboard"
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Licensed to the Technische Universität Darmstadt under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The Technische Universität Darmstadt
|
|
5
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License.
|
|
8
|
+
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
from unittest.mock import MagicMock, patch
|
|
19
|
+
|
|
20
|
+
from inception_reports.generate_reports_lead import get_unique_tags, plot_project_progress, read_dir
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_get_unique_tags():
|
|
24
|
+
"""
|
|
25
|
+
Test case for the get_unique_tags function.
|
|
26
|
+
|
|
27
|
+
This test case verifies that the get_unique_tags function returns the expected result
|
|
28
|
+
when given a list of projects with tags.
|
|
29
|
+
"""
|
|
30
|
+
projects = [
|
|
31
|
+
{"project_tags": ["tag1", "tag2"]},
|
|
32
|
+
{"project_tags": ["tag2", "tag3"]},
|
|
33
|
+
{"project_tags": ["tag3", "tag4"]},
|
|
34
|
+
]
|
|
35
|
+
expected_result = ["tag1", "tag2", "tag3", "tag4"]
|
|
36
|
+
assert get_unique_tags(projects).sort() == expected_result.sort()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def fake_json_loads(file):
|
|
40
|
+
"""
|
|
41
|
+
Mimics json.load operation for a mocked file object.
|
|
42
|
+
This function will be called by json.load(mocked_open_instance).
|
|
43
|
+
"""
|
|
44
|
+
return {
|
|
45
|
+
"project_name": "project_1",
|
|
46
|
+
"project_tags": ["tag1", "tag2", "tag3"],
|
|
47
|
+
"doc_categories": {
|
|
48
|
+
"ANNOTATION_IN_PROGRESS": 12,
|
|
49
|
+
"ANNOTATION_FINISHED": 5,
|
|
50
|
+
"CURATION_IN_PROGRESS": 0,
|
|
51
|
+
"CURATION_FINISHED": 0,
|
|
52
|
+
"NEW": 4,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@patch("os.listdir", MagicMock(return_value=["project1.json"]))
|
|
58
|
+
@patch("builtins.open", new_callable=MagicMock)
|
|
59
|
+
@patch("json.load", MagicMock(side_effect=fake_json_loads))
|
|
60
|
+
def test_read_dir(mock_open):
|
|
61
|
+
"""
|
|
62
|
+
Test case for the read_dir function.
|
|
63
|
+
|
|
64
|
+
This test case verifies that the read_dir function correctly reads the contents of a directory and returns the expected result.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
mock_open: A mock object for the built-in open function.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
None
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
dir = "some/dir"
|
|
74
|
+
expected = [
|
|
75
|
+
{
|
|
76
|
+
"project_name": "project_1",
|
|
77
|
+
"project_tags": ["tag1", "tag2", "tag3"],
|
|
78
|
+
"doc_categories": {
|
|
79
|
+
"ANNOTATION_IN_PROGRESS": 12,
|
|
80
|
+
"ANNOTATION_FINISHED": 5,
|
|
81
|
+
"CURATION_IN_PROGRESS": 0,
|
|
82
|
+
"CURATION_FINISHED": 0,
|
|
83
|
+
"NEW": 4,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
result = read_dir(dir)
|
|
89
|
+
|
|
90
|
+
mock_open.assert_called_once_with(os.path.join(dir, "project1.json"), "r")
|
|
91
|
+
assert result == expected, "Expected result does not match the actual result."
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_plot_project_progress():
|
|
95
|
+
"""
|
|
96
|
+
Test case for the plot_project_progress function.
|
|
97
|
+
"""
|
|
98
|
+
project_data = {
|
|
99
|
+
"project_name": "project_1",
|
|
100
|
+
"project_tags": ["tag1", "tag2", "tag3"],
|
|
101
|
+
"doc_categories": {
|
|
102
|
+
"ANNOTATION_IN_PROGRESS": 12,
|
|
103
|
+
"ANNOTATION_FINISHED": 5,
|
|
104
|
+
"CURATION_IN_PROGRESS": 0,
|
|
105
|
+
"CURATION_FINISHED": 0,
|
|
106
|
+
"NEW": 4,
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
plot_project_progress(project_data)
|
|
111
|
+
assert True, "Should not raise any exceptions"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Licensed to the Technische Universität Darmstadt under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The Technische Universität Darmstadt
|
|
5
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License.
|
|
8
|
+
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import os
|
|
19
|
+
import tempfile
|
|
20
|
+
import zipfile
|
|
21
|
+
from unittest.mock import Mock, patch
|
|
22
|
+
|
|
23
|
+
from inception_reports.generate_reports_manager import find_element_by_name, read_dir
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_find_element_by_name():
|
|
27
|
+
MockElement_1 = Mock()
|
|
28
|
+
MockElement_1.configure_mock(**{"name": "element1", "uiName": "UI Element 1"})
|
|
29
|
+
MockElement_2 = Mock()
|
|
30
|
+
MockElement_2.configure_mock(**{"name": "element2", "uiName": "UI Element 2"})
|
|
31
|
+
MockElement_3 = Mock()
|
|
32
|
+
MockElement_3.configure_mock(**{"name": "element3", "uiName": "UI Element 3"})
|
|
33
|
+
|
|
34
|
+
element_list = [MockElement_1, MockElement_2, MockElement_3]
|
|
35
|
+
|
|
36
|
+
result = find_element_by_name(element_list, "element2")
|
|
37
|
+
assert result == "UI Element 2", "Should return the uiName of the found element"
|
|
38
|
+
|
|
39
|
+
result = find_element_by_name(element_list, "element4")
|
|
40
|
+
assert result == "element4", "Should return the last part of the name if not found"
|
|
41
|
+
|
|
42
|
+
result = find_element_by_name([], "element2")
|
|
43
|
+
assert result == "element2", "Should handle empty input list"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@patch('cassis.load_cas_from_json', return_value="MockCASObject")
|
|
48
|
+
@patch('os.listdir', return_value=['project1.zip'])
|
|
49
|
+
@patch('zipfile.is_zipfile', return_value=True)
|
|
50
|
+
@patch('shutil.rmtree')
|
|
51
|
+
def test_read_dir_correctly_parses_zip_files(mock_rmtree, mock_is_zipfile, mock_listdir, mock_cas_loader):
|
|
52
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
53
|
+
zip_name = "project1.zip"
|
|
54
|
+
zip_path = os.path.join(temp_dir, zip_name)
|
|
55
|
+
with zipfile.ZipFile(zip_path, 'w') as zipf:
|
|
56
|
+
project_meta = {
|
|
57
|
+
"description": "A mock project #tag1 #tag2",
|
|
58
|
+
"source_documents": ["doc1.txt", "doc2.txt"]
|
|
59
|
+
}
|
|
60
|
+
zipf.writestr('exportedproject.json', json.dumps(project_meta))
|
|
61
|
+
|
|
62
|
+
annotation_content = {"dummy": "content"}
|
|
63
|
+
zipf.writestr('annotation/doc1/annotator1.json', json.dumps(annotation_content))
|
|
64
|
+
|
|
65
|
+
projects = read_dir(temp_dir)
|
|
66
|
+
|
|
67
|
+
assert len(projects) == 1, "Should correctly parse zip files and extract project data"
|
|
68
|
+
project = projects[0]
|
|
69
|
+
print(project['annotations'])
|
|
70
|
+
assert project['name'] == zip_name, "Project name should match the zip file name"
|
|
71
|
+
assert set(project['tags']) == {"tag1", "tag2"}, "Should extract correct tags from project metadata"
|
|
72
|
+
assert project['documents'] == ["doc1.txt", "doc2.txt"], "Should list all source documents"
|
|
73
|
+
assert 'doc1' in project['annotations'], "Should include annotations in the project data"
|
|
74
|
+
assert project['annotations']['doc1'] == "MockCASObject", "Should load CAS objects for annotations"
|
|
75
|
+
|