clams-python 1.4.0__tar.gz → 1.5.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.
Files changed (38) hide show
  1. {clams_python-1.4.0/clams_python.egg-info → clams_python-1.5.0}/PKG-INFO +2 -2
  2. clams_python-1.5.0/VERSION +1 -0
  3. {clams_python-1.4.0 → clams_python-1.5.0}/clams/app/__init__.py +31 -1
  4. {clams_python-1.4.0 → clams_python-1.5.0}/clams/appmetadata/__init__.py +2 -1
  5. clams_python-1.5.0/clams/ver/__init__.py +1 -0
  6. {clams_python-1.4.0 → clams_python-1.5.0/clams_python.egg-info}/PKG-INFO +2 -2
  7. {clams_python-1.4.0 → clams_python-1.5.0}/clams_python.egg-info/requires.txt +1 -1
  8. {clams_python-1.4.0 → clams_python-1.5.0}/requirements.txt +1 -1
  9. {clams_python-1.4.0 → clams_python-1.5.0}/tests/test_clamsapp.py +2 -2
  10. clams_python-1.4.0/VERSION +0 -1
  11. clams_python-1.4.0/clams/ver/__init__.py +0 -1
  12. {clams_python-1.4.0 → clams_python-1.5.0}/LICENSE +0 -0
  13. {clams_python-1.4.0 → clams_python-1.5.0}/MANIFEST.in +0 -0
  14. {clams_python-1.4.0 → clams_python-1.5.0}/README.md +0 -0
  15. {clams_python-1.4.0 → clams_python-1.5.0}/clams/__init__.py +0 -0
  16. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/__init__.py +0 -0
  17. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/.dockerignore.template +0 -0
  18. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/.gitignore.template +0 -0
  19. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/Containerfile.template +0 -0
  20. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/LICENSE.template +0 -0
  21. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/README.md.template +0 -0
  22. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/app.py.template +0 -0
  23. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/cli.py.template +0 -0
  24. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/metadata.py.template +0 -0
  25. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/app/requirements.txt.template +0 -0
  26. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/gha/for-clams-team.md.template +0 -0
  27. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/gha/workflows/issue-apps-project.yml.template +0 -0
  28. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/gha/workflows/issue-assign.yml.template +0 -0
  29. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/gha/workflows/issue-close.yml.template +0 -0
  30. {clams_python-1.4.0 → clams_python-1.5.0}/clams/develop/templates/gha/workflows/publish.yml.template +0 -0
  31. {clams_python-1.4.0 → clams_python-1.5.0}/clams/restify/__init__.py +0 -0
  32. {clams_python-1.4.0 → clams_python-1.5.0}/clams/serve/__init__.py +0 -0
  33. {clams_python-1.4.0 → clams_python-1.5.0}/clams_python.egg-info/SOURCES.txt +0 -0
  34. {clams_python-1.4.0 → clams_python-1.5.0}/clams_python.egg-info/dependency_links.txt +0 -0
  35. {clams_python-1.4.0 → clams_python-1.5.0}/clams_python.egg-info/entry_points.txt +0 -0
  36. {clams_python-1.4.0 → clams_python-1.5.0}/clams_python.egg-info/top_level.txt +0 -0
  37. {clams_python-1.4.0 → clams_python-1.5.0}/setup.cfg +0 -0
  38. {clams_python-1.4.0 → clams_python-1.5.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clams-python
3
- Version: 1.4.0
3
+ Version: 1.5.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.10
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
- Requires-Dist: mmif-python==1.2.1
17
+ Requires-Dist: mmif-python==1.3.1
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.5.0
@@ -13,7 +13,11 @@ __all__ = ['ClamsApp']
13
13
  from typing import Union, Any, Optional, Dict, List, Tuple
14
14
 
15
15
  from mmif import Mmif, Document, DocumentTypes, View
16
- from mmif.utils.cli.describe import generate_param_hash # pytype: disable=import-error
16
+ from mmif.utils.video_document_helper import (
17
+ SamplingMode, SAMPLING_MODE_DESCRIPTIONS, SAMPLING_MODE_DEFAULT,
18
+ _sampling_mode,
19
+ )
20
+ from mmif.utils.workflow_helper import generate_param_hash # pytype: disable=import-error
17
21
  from clams.appmetadata import AppMetadata, real_valued_primitives, python_type, map_param_kv_delimiter
18
22
 
19
23
  logging.basicConfig(
@@ -22,6 +26,16 @@ logging.basicConfig(
22
26
  datefmt="%Y-%m-%d %H:%M:%S")
23
27
 
24
28
 
29
+ _sampling_mode_choices = [m.value for m in SamplingMode]
30
+ _sampling_mode_description = (
31
+ 'Sampling mode for TimeFrame annotations. '
32
+ 'Has no effect when the app does not process TimeFrames. '
33
+ + ' '.join(
34
+ f'"{m.value}" {SAMPLING_MODE_DESCRIPTIONS[m]}'
35
+ for m in SamplingMode
36
+ )
37
+ )
38
+
25
39
  falsy_values = [
26
40
  'False',
27
41
  'false',
@@ -55,6 +69,19 @@ class ClamsApp(ABC):
55
69
  'name': 'hwFetch', 'type': 'boolean', 'choices': None, 'default': False, 'multivalued': False,
56
70
  'description': 'The hardware information (architecture, GPU and vRAM) will be recorded in the view metadata',
57
71
  },
72
+ # tfSamplingMode is universal (not per-app) because it controls
73
+ # how vdh.extract_frames_by_mode() selects frames from TimeFrames.
74
+ # The value is intercepted in annotate() and pushed into a
75
+ # contextvars.ContextVar so that any vdh call inside _annotate()
76
+ # picks it up automatically — app developers never need to handle
77
+ # this parameter themselves.
78
+ {
79
+ 'name': 'tfSamplingMode', 'type': 'string',
80
+ 'choices': _sampling_mode_choices,
81
+ 'default': SAMPLING_MODE_DEFAULT.value,
82
+ 'multivalued': False,
83
+ 'description': _sampling_mode_description,
84
+ },
58
85
  ]
59
86
 
60
87
  # this key is used to store users' raw input params in the parameter dict
@@ -148,6 +175,9 @@ class ClamsApp(ABC):
148
175
  refined = self._refine_params(**runtime_params)
149
176
  self.logger.debug(f"Refined parameters: {refined}")
150
177
  pretty = refined.get('pretty', False)
178
+ sampling_mode_str = refined.pop('tfSamplingMode', None)
179
+ if sampling_mode_str is not None:
180
+ _sampling_mode.set(SamplingMode(sampling_mode_str))
151
181
  t = datetime.now()
152
182
  with warnings.catch_warnings(record=True) as ws:
153
183
  annotated, cuda_profiler = self._profile_cuda_memory(self._annotate)(mmif, **refined)
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import os
2
3
  import shutil
3
4
  import subprocess
@@ -523,4 +524,4 @@ class AppMetadata(pydantic.BaseModel):
523
524
 
524
525
 
525
526
  if __name__ == '__main__':
526
- print(AppMetadata.schema_json(indent=2))
527
+ print(json.dumps(AppMetadata.model_json_schema(), indent=2))
@@ -0,0 +1 @@
1
+ __version__ = "1.5.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clams-python
3
- Version: 1.4.0
3
+ Version: 1.5.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.10
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
- Requires-Dist: mmif-python==1.2.1
17
+ Requires-Dist: mmif-python==1.3.1
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.2.1
1
+ mmif-python==1.3.1
2
2
  Flask>=2
3
3
  Flask-RESTful>=0.3.9
4
4
  gunicorn>=20
@@ -1,4 +1,4 @@
1
- mmif-python==1.2.1
1
+ mmif-python==1.3.1
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), 5) # universal (pretty, runningtime, hwfetch) + `raise_error` in metadata.py + `multivalued_param`
256
+ self.assertEqual(len(v3.metadata.appConfiguration), 6) # universal (pretty, runningTime, hwFetch, tfSamplingMode) + `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), 5)
263
+ self.assertEqual(len(v4.metadata.appConfiguration), 6)
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.4.0
@@ -1 +0,0 @@
1
- __version__ = "1.4.0"
File without changes
File without changes
File without changes
File without changes
File without changes