clams-python 1.2.5__tar.gz → 1.3.0__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.
- {clams_python-1.2.5/clams_python.egg-info → clams_python-1.3.0}/PKG-INFO +2 -2
- clams_python-1.3.0/VERSION +1 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/app/__init__.py +32 -1
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/Containerfile.template +1 -1
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/mmif_utils/source.py +16 -3
- clams_python-1.3.0/clams/ver/__init__.py +1 -0
- {clams_python-1.2.5 → clams_python-1.3.0/clams_python.egg-info}/PKG-INFO +2 -2
- {clams_python-1.2.5 → clams_python-1.3.0}/clams_python.egg-info/requires.txt +1 -1
- {clams_python-1.2.5 → clams_python-1.3.0}/requirements.txt +1 -1
- {clams_python-1.2.5 → clams_python-1.3.0}/tests/test_clamsapp.py +2 -2
- clams_python-1.2.5/VERSION +0 -1
- clams_python-1.2.5/clams/ver/__init__.py +0 -1
- {clams_python-1.2.5 → clams_python-1.3.0}/LICENSE +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/MANIFEST.in +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/README.md +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/__init__.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/appmetadata/__init__.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/__init__.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/.dockerignore.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/.gitignore.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/LICENSE.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/README.md.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/app.py.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/cli.py.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/metadata.py.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/requirements.txt.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/gha/for-clams-team.md.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/gha/workflows/issue-apps-project.yml.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/gha/workflows/issue-assign.yml.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/gha/workflows/issue-close.yml.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/gha/workflows/publish.yml.template +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/mmif_utils/__init__.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/mmif_utils/rewind.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/restify/__init__.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams/serve/__init__.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams_python.egg-info/SOURCES.txt +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams_python.egg-info/dependency_links.txt +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams_python.egg-info/entry_points.txt +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/clams_python.egg-info/top_level.txt +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/setup.cfg +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/setup.py +0 -0
- {clams_python-1.2.5 → clams_python-1.3.0}/tests/test_clamscli.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: clams-python
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A collection of APIs to develop CLAMS app for python
|
|
5
5
|
Home-page: https://clams.ai
|
|
6
6
|
Author: Brandeis Lab for Linguistics and Computation
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
14
14
|
Requires-Python: >=3.8
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: mmif-python==1.0.
|
|
17
|
+
Requires-Dist: mmif-python==1.0.18
|
|
18
18
|
Requires-Dist: Flask>=2
|
|
19
19
|
Requires-Dist: Flask-RESTful>=0.3.9
|
|
20
20
|
Requires-Dist: gunicorn>=20
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.3.0
|
|
@@ -5,6 +5,7 @@ import sys
|
|
|
5
5
|
import warnings
|
|
6
6
|
from abc import ABC, abstractmethod
|
|
7
7
|
from contextlib import contextmanager
|
|
8
|
+
from datetime import datetime
|
|
8
9
|
from urllib import parse as urlparser
|
|
9
10
|
|
|
10
11
|
__all__ = ['ClamsApp']
|
|
@@ -44,6 +45,14 @@ class ClamsApp(ABC):
|
|
|
44
45
|
'name': 'pretty', 'type': 'boolean', 'choices': None, 'default': False, 'multivalued': False,
|
|
45
46
|
'description': 'The JSON body of the HTTP response will be re-formatted with 2-space indentation',
|
|
46
47
|
},
|
|
48
|
+
{
|
|
49
|
+
'name': 'runningTime', 'type': 'boolean', 'choices': None, 'default': False, 'multivalued': False,
|
|
50
|
+
'description': 'The running time of the app will be recorded in the view metadata',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
'name': 'hwFetch', 'type': 'boolean', 'choices': None, 'default': False, 'multivalued': False,
|
|
54
|
+
'description': 'The hardware information (architecture, GPU and vRAM) will be recorded in the view metadata',
|
|
55
|
+
},
|
|
47
56
|
]
|
|
48
57
|
|
|
49
58
|
# this key is used to store users' raw input params in the parameter dict
|
|
@@ -136,6 +145,7 @@ class ClamsApp(ABC):
|
|
|
136
145
|
refined = self._refine_params(**runtime_params)
|
|
137
146
|
self.logger.debug(f"Refined parameters: {refined}")
|
|
138
147
|
pretty = refined.get('pretty', False)
|
|
148
|
+
t = datetime.now()
|
|
139
149
|
with warnings.catch_warnings(record=True) as ws:
|
|
140
150
|
annotated = self._annotate(mmif, **refined)
|
|
141
151
|
if ws:
|
|
@@ -144,6 +154,27 @@ class ClamsApp(ABC):
|
|
|
144
154
|
warnings_view = annotated.new_view()
|
|
145
155
|
self.sign_view(warnings_view, refined)
|
|
146
156
|
warnings_view.metadata.warnings = issued_warnings
|
|
157
|
+
td = datetime.now() - t
|
|
158
|
+
runningTime = refined.get('runningTime', False)
|
|
159
|
+
hwFetch = refined.get('hwFetch', False)
|
|
160
|
+
runtime_recs = {}
|
|
161
|
+
if hwFetch:
|
|
162
|
+
import platform, shutil, subprocess
|
|
163
|
+
runtime_recs['architecture'] = platform.machine()
|
|
164
|
+
# runtime_recs['processor'] = platform.processor() # this only works on Windows
|
|
165
|
+
runtime_recs['cuda'] = []
|
|
166
|
+
if shutil.which('nvidia-smi'):
|
|
167
|
+
for gpu in subprocess.run(['nvidia-smi', '--query-gpu=name,memory.total', '--format=csv,noheader'],
|
|
168
|
+
stdout=subprocess.PIPE).stdout.decode('utf-8').strip().split('\n'):
|
|
169
|
+
name, mem = gpu.split(', ')
|
|
170
|
+
runtime_recs['cuda'].append(f'{name} ({mem})')
|
|
171
|
+
for annotated_view in annotated.views:
|
|
172
|
+
if annotated_view.metadata.app == self.metadata.identifier:
|
|
173
|
+
if runningTime:
|
|
174
|
+
annotated_view.metadata.set_additional_property('appRunningTime', str(td))
|
|
175
|
+
if len(runtime_recs) > 0:
|
|
176
|
+
annotated_view.metadata.set_additional_property('appRunningHardware', runtime_recs)
|
|
177
|
+
|
|
147
178
|
return annotated.serialize(pretty=pretty, sanitize=True)
|
|
148
179
|
|
|
149
180
|
@abstractmethod
|
|
@@ -260,7 +291,7 @@ class ClamsApp(ABC):
|
|
|
260
291
|
break
|
|
261
292
|
if error_view is None:
|
|
262
293
|
error_view = mmif.new_view()
|
|
263
|
-
self.sign_view(error_view,
|
|
294
|
+
self.sign_view(error_view, runtime_conf)
|
|
264
295
|
exc_info = sys.exc_info()
|
|
265
296
|
error_view.set_error(f'{exc_info[0]}: {exc_info[1]}',
|
|
266
297
|
'\t\n'.join(traceback.format_tb(exc_info[2])))
|
{clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/Containerfile.template
RENAMED
|
@@ -25,7 +25,7 @@ ENV HF_HOME="/cache/huggingface"
|
|
|
25
25
|
# https://pytorch.org/docs/stable/hub.html#where-are-my-downloaded-models-saved
|
|
26
26
|
ENV TORCH_HOME="/cache/torch"
|
|
27
27
|
|
|
28
|
-
RUN mkdir /cache ; rm -rf /root/.cache
|
|
28
|
+
RUN mkdir /cache ; rm -rf /root/.cache ; ln -s /cache /root/.cache
|
|
29
29
|
################################################################################
|
|
30
30
|
|
|
31
31
|
################################################################################
|
|
@@ -203,9 +203,10 @@ def generate_source_mmif_from_file(documents, prefix=None, scheme='file', **igno
|
|
|
203
203
|
raise ValueError(f'file location must be an absolute path, or --prefix must be used; given \"{location}\".')
|
|
204
204
|
elif prefix and not location.is_absolute():
|
|
205
205
|
location = prefix / location
|
|
206
|
+
location = str(location)
|
|
206
207
|
doc = Document()
|
|
207
208
|
doc.at_type = at_types[mime.split('/', maxsplit=1)[0]]
|
|
208
|
-
doc.properties.location = f"{location_uri.scheme}://{location}"
|
|
209
|
+
doc.properties.location = f"{location_uri.scheme}://{location if not location.startswith(location_uri.scheme) else location[len(location_uri.scheme)+3:]}"
|
|
209
210
|
doc.properties.id = f'd{doc_id}'
|
|
210
211
|
doc.properties.mime = mime
|
|
211
212
|
pl.add_document(doc)
|
|
@@ -225,7 +226,14 @@ def describe_argparser():
|
|
|
225
226
|
|
|
226
227
|
|
|
227
228
|
def prep_argparser(**kwargs):
|
|
228
|
-
|
|
229
|
+
import pkgutil
|
|
230
|
+
import re
|
|
231
|
+
import importlib
|
|
232
|
+
discovered_docloc_plugins = {
|
|
233
|
+
name[len('mmif_docloc_'):]: importlib.import_module(name) for _, name, _ in pkgutil.iter_modules() if
|
|
234
|
+
re.match(r'mmif[-_]docloc[-_]', name)
|
|
235
|
+
}
|
|
236
|
+
parser = argparse.ArgumentParser(description=describe_argparser()[1], formatter_class=argparse.RawTextHelpFormatter, **kwargs)
|
|
229
237
|
parser.add_argument(
|
|
230
238
|
'documents',
|
|
231
239
|
default=None,
|
|
@@ -255,12 +263,17 @@ def prep_argparser(**kwargs):
|
|
|
255
263
|
nargs='?',
|
|
256
264
|
help='A name of a file to capture a generated MMIF json. When not given, MMIF is printed to stdout.'
|
|
257
265
|
)
|
|
266
|
+
scheme_help = 'A scheme to associate with the document location URI. When not given, the default scheme is `file://`.'
|
|
267
|
+
if len(discovered_docloc_plugins) > 0:
|
|
268
|
+
plugin_help = [f'"{scheme_name}" ({scheme_plugin.help() if "help" in dir(scheme_plugin) else "help msg not provided by developer"})'
|
|
269
|
+
for scheme_name, scheme_plugin in discovered_docloc_plugins.items()]
|
|
270
|
+
scheme_help += ' (AVAILABLE ADDITIONAL SCHEMES) ' + ', '.join(plugin_help)
|
|
258
271
|
parser.add_argument(
|
|
259
272
|
'-s', '--scheme',
|
|
260
273
|
default='file',
|
|
261
274
|
action='store',
|
|
262
275
|
nargs='?',
|
|
263
|
-
help=
|
|
276
|
+
help=scheme_help
|
|
264
277
|
)
|
|
265
278
|
return parser
|
|
266
279
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.3.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: clams-python
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A collection of APIs to develop CLAMS app for python
|
|
5
5
|
Home-page: https://clams.ai
|
|
6
6
|
Author: Brandeis Lab for Linguistics and Computation
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
14
14
|
Requires-Python: >=3.8
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: mmif-python==1.0.
|
|
17
|
+
Requires-Dist: mmif-python==1.0.18
|
|
18
18
|
Requires-Dist: Flask>=2
|
|
19
19
|
Requires-Dist: Flask-RESTful>=0.3.9
|
|
20
20
|
Requires-Dist: gunicorn>=20
|
|
@@ -253,14 +253,14 @@ class TestClamsApp(unittest.TestCase):
|
|
|
253
253
|
args3 = {'undefined_param1': ['value1']}
|
|
254
254
|
self.app.sign_view(v3, self.app._refine_params(**args3))
|
|
255
255
|
self.assertEqual(len(v3.metadata.parameters), 1)
|
|
256
|
-
self.assertEqual(len(v3.metadata.appConfiguration),
|
|
256
|
+
self.assertEqual(len(v3.metadata.appConfiguration), 5) # universal (pretty, runningtime, hwfetch) + `raise_error` in metadata.py + `multivalued_param`
|
|
257
257
|
self.assertEqual(v3.metadata.appConfiguration['multivalued_param'], [])
|
|
258
258
|
v4 = m.new_view()
|
|
259
259
|
multiple_values = ['value1', 'value2']
|
|
260
260
|
args4 = {'multivalued_param': multiple_values}
|
|
261
261
|
self.app.sign_view(v4, self.app._refine_params(**args4))
|
|
262
262
|
self.assertEqual(len(v4.metadata.parameters), 1)
|
|
263
|
-
self.assertEqual(len(v4.metadata.appConfiguration),
|
|
263
|
+
self.assertEqual(len(v4.metadata.appConfiguration), 5)
|
|
264
264
|
self.assertEqual(len(v4.metadata.parameters['multivalued_param']), len(str(multiple_values)))
|
|
265
265
|
|
|
266
266
|
def test_annotate(self):
|
clams_python-1.2.5/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.2.5
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.2.5"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/.dockerignore.template
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/app/requirements.txt.template
RENAMED
|
File without changes
|
{clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/gha/for-clams-team.md.template
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clams_python-1.2.5 → clams_python-1.3.0}/clams/develop/templates/gha/workflows/publish.yml.template
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|