clams-python 1.2.6__tar.gz → 1.3.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.
Files changed (42) hide show
  1. {clams_python-1.2.6/clams_python.egg-info → clams_python-1.3.1}/PKG-INFO +2 -2
  2. clams_python-1.3.1/VERSION +1 -0
  3. {clams_python-1.2.6 → clams_python-1.3.1}/clams/app/__init__.py +32 -0
  4. {clams_python-1.2.6 → clams_python-1.3.1}/clams/mmif_utils/rewind.py +3 -1
  5. {clams_python-1.2.6 → clams_python-1.3.1}/clams/mmif_utils/source.py +3 -0
  6. clams_python-1.3.1/clams/ver/__init__.py +1 -0
  7. {clams_python-1.2.6 → clams_python-1.3.1/clams_python.egg-info}/PKG-INFO +2 -2
  8. {clams_python-1.2.6 → clams_python-1.3.1}/clams_python.egg-info/requires.txt +1 -1
  9. {clams_python-1.2.6 → clams_python-1.3.1}/requirements.txt +1 -1
  10. {clams_python-1.2.6 → clams_python-1.3.1}/tests/test_clamsapp.py +2 -2
  11. clams_python-1.2.6/VERSION +0 -1
  12. clams_python-1.2.6/clams/ver/__init__.py +0 -1
  13. {clams_python-1.2.6 → clams_python-1.3.1}/LICENSE +0 -0
  14. {clams_python-1.2.6 → clams_python-1.3.1}/MANIFEST.in +0 -0
  15. {clams_python-1.2.6 → clams_python-1.3.1}/README.md +0 -0
  16. {clams_python-1.2.6 → clams_python-1.3.1}/clams/__init__.py +0 -0
  17. {clams_python-1.2.6 → clams_python-1.3.1}/clams/appmetadata/__init__.py +0 -0
  18. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/__init__.py +0 -0
  19. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/.dockerignore.template +0 -0
  20. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/.gitignore.template +0 -0
  21. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/Containerfile.template +0 -0
  22. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/LICENSE.template +0 -0
  23. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/README.md.template +0 -0
  24. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/app.py.template +0 -0
  25. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/cli.py.template +0 -0
  26. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/metadata.py.template +0 -0
  27. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/app/requirements.txt.template +0 -0
  28. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/gha/for-clams-team.md.template +0 -0
  29. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/gha/workflows/issue-apps-project.yml.template +0 -0
  30. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/gha/workflows/issue-assign.yml.template +0 -0
  31. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/gha/workflows/issue-close.yml.template +0 -0
  32. {clams_python-1.2.6 → clams_python-1.3.1}/clams/develop/templates/gha/workflows/publish.yml.template +0 -0
  33. {clams_python-1.2.6 → clams_python-1.3.1}/clams/mmif_utils/__init__.py +0 -0
  34. {clams_python-1.2.6 → clams_python-1.3.1}/clams/restify/__init__.py +0 -0
  35. {clams_python-1.2.6 → clams_python-1.3.1}/clams/serve/__init__.py +0 -0
  36. {clams_python-1.2.6 → clams_python-1.3.1}/clams_python.egg-info/SOURCES.txt +0 -0
  37. {clams_python-1.2.6 → clams_python-1.3.1}/clams_python.egg-info/dependency_links.txt +0 -0
  38. {clams_python-1.2.6 → clams_python-1.3.1}/clams_python.egg-info/entry_points.txt +0 -0
  39. {clams_python-1.2.6 → clams_python-1.3.1}/clams_python.egg-info/top_level.txt +0 -0
  40. {clams_python-1.2.6 → clams_python-1.3.1}/setup.cfg +0 -0
  41. {clams_python-1.2.6 → clams_python-1.3.1}/setup.py +0 -0
  42. {clams_python-1.2.6 → clams_python-1.3.1}/tests/test_clamscli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clams-python
3
- Version: 1.2.6
3
+ Version: 1.3.1
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.18
17
+ Requires-Dist: mmif-python==1.0.19
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.1
@@ -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']
@@ -30,6 +31,7 @@ falsy_values = [
30
31
  False
31
32
  ]
32
33
 
34
+
33
35
  class ClamsApp(ABC):
34
36
  """
35
37
  An abstract class to define API's for ClamsApps. A CLAMS app should inherit
@@ -44,6 +46,14 @@ class ClamsApp(ABC):
44
46
  'name': 'pretty', 'type': 'boolean', 'choices': None, 'default': False, 'multivalued': False,
45
47
  'description': 'The JSON body of the HTTP response will be re-formatted with 2-space indentation',
46
48
  },
49
+ {
50
+ 'name': 'runningTime', 'type': 'boolean', 'choices': None, 'default': False, 'multivalued': False,
51
+ 'description': 'The running time of the app will be recorded in the view metadata',
52
+ },
53
+ {
54
+ 'name': 'hwFetch', 'type': 'boolean', 'choices': None, 'default': False, 'multivalued': False,
55
+ 'description': 'The hardware information (architecture, GPU and vRAM) will be recorded in the view metadata',
56
+ },
47
57
  ]
48
58
 
49
59
  # this key is used to store users' raw input params in the parameter dict
@@ -136,6 +146,7 @@ class ClamsApp(ABC):
136
146
  refined = self._refine_params(**runtime_params)
137
147
  self.logger.debug(f"Refined parameters: {refined}")
138
148
  pretty = refined.get('pretty', False)
149
+ t = datetime.now()
139
150
  with warnings.catch_warnings(record=True) as ws:
140
151
  annotated = self._annotate(mmif, **refined)
141
152
  if ws:
@@ -144,6 +155,27 @@ class ClamsApp(ABC):
144
155
  warnings_view = annotated.new_view()
145
156
  self.sign_view(warnings_view, refined)
146
157
  warnings_view.metadata.warnings = issued_warnings
158
+ td = datetime.now() - t
159
+ runningTime = refined.get('runningTime', False)
160
+ hwFetch = refined.get('hwFetch', False)
161
+ runtime_recs = {}
162
+ if hwFetch:
163
+ import platform, shutil, subprocess
164
+ runtime_recs['architecture'] = platform.machine()
165
+ # runtime_recs['processor'] = platform.processor() # this only works on Windows
166
+ runtime_recs['cuda'] = []
167
+ if shutil.which('nvidia-smi'):
168
+ for gpu in subprocess.run(['nvidia-smi', '--query-gpu=name,memory.total', '--format=csv,noheader'],
169
+ stdout=subprocess.PIPE).stdout.decode('utf-8').strip().split('\n'):
170
+ name, mem = gpu.split(', ')
171
+ runtime_recs['cuda'].append(f'{name} ({mem})')
172
+ for annotated_view in annotated.views:
173
+ if annotated_view.metadata.app == self.metadata.identifier:
174
+ if runningTime:
175
+ annotated_view.metadata.set_additional_property('appRunningTime', str(td))
176
+ if len(runtime_recs) > 0:
177
+ annotated_view.metadata.set_additional_property('appRunningHardware', runtime_recs)
178
+
147
179
  return annotated.serialize(pretty=pretty, sanitize=True)
148
180
 
149
181
  @abstractmethod
@@ -1,7 +1,9 @@
1
+ """
2
+ This module provides a CLI to rewind a MMIF from a CLAMS pipeline.
3
+ """
1
4
  import argparse
2
5
  import sys
3
6
  import textwrap
4
- from pathlib import Path as P
5
7
 
6
8
  import mmif
7
9
 
@@ -1,3 +1,6 @@
1
+ """
2
+ This module provides a class for creating a "source" MMIF JSON object.
3
+ """
1
4
  import argparse
2
5
  import itertools
3
6
  import json
@@ -0,0 +1 @@
1
+ __version__ = "1.3.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clams-python
3
- Version: 1.2.6
3
+ Version: 1.3.1
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.18
17
+ Requires-Dist: mmif-python==1.0.19
18
18
  Requires-Dist: Flask>=2
19
19
  Requires-Dist: Flask-RESTful>=0.3.9
20
20
  Requires-Dist: gunicorn>=20
@@ -1,4 +1,4 @@
1
- mmif-python==1.0.18
1
+ mmif-python==1.0.19
2
2
  Flask>=2
3
3
  Flask-RESTful>=0.3.9
4
4
  gunicorn>=20
@@ -1,4 +1,4 @@
1
- mmif-python==1.0.18
1
+ mmif-python==1.0.19
2
2
 
3
3
  Flask>=2
4
4
  Flask-RESTful>=0.3.9
@@ -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), 3) # universal (pretty) + `raise_error` in metadata.py + `multivalued_param`
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), 3)
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):
@@ -1 +0,0 @@
1
- 1.2.6
@@ -1 +0,0 @@
1
- __version__ = "1.2.6"
File without changes
File without changes
File without changes
File without changes
File without changes