clams-python 1.1.1__tar.gz → 1.1.2__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 (41) hide show
  1. {clams-python-1.1.1/clams_python.egg-info → clams-python-1.1.2}/PKG-INFO +2 -2
  2. clams-python-1.1.2/VERSION +1 -0
  3. {clams-python-1.1.1 → clams-python-1.1.2}/clams/app/__init__.py +2 -4
  4. {clams-python-1.1.1 → clams-python-1.1.2}/clams/mmif_utils/rewind.py +28 -38
  5. clams-python-1.1.2/clams/ver/__init__.py +1 -0
  6. {clams-python-1.1.1 → clams-python-1.1.2/clams_python.egg-info}/PKG-INFO +2 -2
  7. {clams-python-1.1.1 → clams-python-1.1.2}/clams_python.egg-info/requires.txt +1 -1
  8. {clams-python-1.1.1 → clams-python-1.1.2}/requirements.txt +1 -1
  9. {clams-python-1.1.1 → clams-python-1.1.2}/tests/test_clamsapp.py +6 -1
  10. clams-python-1.1.1/VERSION +0 -1
  11. clams-python-1.1.1/clams/ver/__init__.py +0 -1
  12. {clams-python-1.1.1 → clams-python-1.1.2}/LICENSE +0 -0
  13. {clams-python-1.1.1 → clams-python-1.1.2}/MANIFEST.in +0 -0
  14. {clams-python-1.1.1 → clams-python-1.1.2}/README.md +0 -0
  15. {clams-python-1.1.1 → clams-python-1.1.2}/clams/__init__.py +0 -0
  16. {clams-python-1.1.1 → clams-python-1.1.2}/clams/appmetadata/__init__.py +0 -0
  17. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/__init__.py +0 -0
  18. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/.dockerignore.template +0 -0
  19. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/.gitignore.template +0 -0
  20. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/Containerfile.template +0 -0
  21. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/LICENSE.template +0 -0
  22. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/README.md.template +0 -0
  23. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/app.py.template +0 -0
  24. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/metadata.py.template +0 -0
  25. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/app/requirements.txt.template +0 -0
  26. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/gha/for-clams-team.md.template +0 -0
  27. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/gha/workflows/issue-apps-project.yml.template +0 -0
  28. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/gha/workflows/issue-assign.yml.template +0 -0
  29. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/gha/workflows/issue-close.yml.template +0 -0
  30. {clams-python-1.1.1 → clams-python-1.1.2}/clams/develop/templates/gha/workflows/publish.yml.template +0 -0
  31. {clams-python-1.1.1 → clams-python-1.1.2}/clams/mmif_utils/__init__.py +0 -0
  32. {clams-python-1.1.1 → clams-python-1.1.2}/clams/mmif_utils/source.py +0 -0
  33. {clams-python-1.1.1 → clams-python-1.1.2}/clams/restify/__init__.py +0 -0
  34. {clams-python-1.1.1 → clams-python-1.1.2}/clams/serve/__init__.py +0 -0
  35. {clams-python-1.1.1 → clams-python-1.1.2}/clams_python.egg-info/SOURCES.txt +0 -0
  36. {clams-python-1.1.1 → clams-python-1.1.2}/clams_python.egg-info/dependency_links.txt +0 -0
  37. {clams-python-1.1.1 → clams-python-1.1.2}/clams_python.egg-info/entry_points.txt +0 -0
  38. {clams-python-1.1.1 → clams-python-1.1.2}/clams_python.egg-info/top_level.txt +0 -0
  39. {clams-python-1.1.1 → clams-python-1.1.2}/setup.cfg +0 -0
  40. {clams-python-1.1.1 → clams-python-1.1.2}/setup.py +0 -0
  41. {clams-python-1.1.1 → clams-python-1.1.2}/tests/test_clamscli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clams-python
3
- Version: 1.1.1
3
+ Version: 1.1.2
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.8
17
+ Requires-Dist: mmif-python==1.0.9
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.1.2
@@ -194,8 +194,8 @@ class ClamsApp(ABC):
194
194
  # TODO (krim @ 8/2/23): once all devs understood this change, make runtime_conf a required argument
195
195
  if runtime_conf is None:
196
196
  warnings.warn("`runtime_conf` argument for ClamsApp.sign_view() will "
197
- "no longer be optional in the future. Please just pass "
198
- "`runtime_params` from _annotate() method.",
197
+ "no longer be optional in the future. Please pass `runtime_params` "
198
+ "from _annotate() method.",
199
199
  FutureWarning, stacklevel=2)
200
200
  view.metadata.app = self.metadata.identifier
201
201
  if runtime_conf is not None:
@@ -204,8 +204,6 @@ class ClamsApp(ABC):
204
204
  else:
205
205
  conf = runtime_conf
206
206
  view.metadata.add_parameters(**{k: str(v) for k, v in conf.items()})
207
- # TODO (krim @ 8/2/23): add "refined" parameters as well
208
- # once https://github.com/clamsproject/mmif/issues/208 is resolved
209
207
 
210
208
  def set_error_view(self, mmif: Union[str, dict, Mmif], runtime_conf: Optional[dict] = None) -> Mmif:
211
209
  """
@@ -6,44 +6,27 @@ from pathlib import Path as P
6
6
  import mmif
7
7
 
8
8
 
9
- def is_valid_choice(choice):
10
- try:
11
- ichoice = int(choice)
12
- if 0 <= ichoice:
13
- return ichoice
14
- else:
15
- raise ValueError(f"\nInvalid argument for -n. Please enter a positive integer.")
16
- except ValueError:
17
- raise argparse.ArgumentTypeError(f"\nInvalid argument for -n. Please enter a positive integer.")
18
-
19
- def user_choice(mmif_obj:mmif.Mmif) -> int:
9
+ def prompt_user(mmif_obj: mmif.Mmif) -> int:
20
10
  """
21
11
  Function to ask user to choose the rewind range.
22
-
23
- :param mmif_obj: mmif object
24
- :return: int option number
25
12
  """
26
13
 
27
14
  ## Give a user options (#, "app", "timestamp") - time order
28
15
  n = len(mmif_obj.views)
29
16
  i = 0 # option number
17
+ aname = ""
18
+ a = 0
30
19
  # header
31
- print("\n" + "{:<4} {:<30} {:<100}".format("num", "timestamp", "app"))
32
- for view in mmif_obj.views:
33
- option = "{:<4} {:<30} {:<100}".format(n-i, str(view.metadata.timestamp), str(view.metadata.app))
34
- print(option)
20
+ print("\n" + "{:<8} {:<8} {:<30} {:<100}".format("view-num", "app-num", "timestamp", "app"))
21
+ for view in reversed(mmif_obj.views):
22
+ if view.metadata.app != aname:
23
+ aname = view.metadata.app
24
+ a += 1
35
25
  i += 1
26
+ print("{:<8} {:<8} {:<30} {:<100}".format(i, a, str(view.metadata.timestamp), str(view.metadata.app)))
36
27
 
37
28
  ## User input
38
- while True:
39
- choice = int(input("\nEnter the number to delete from that point by rewinding: "))
40
- try:
41
- if 0 <= choice <= n:
42
- return choice
43
- else:
44
- print(f"\nInvalid choice. Please enter an integer in the range [0, {n}].")
45
- except ValueError:
46
- print("\nInvalid input. Please enter a valid number.")
29
+ return int(input("\nEnter the number to delete from that point by rewinding: "))
47
30
 
48
31
 
49
32
  def rewind_mmif(mmif_obj: mmif.Mmif, choice: int, choice_is_viewnum: bool = True) -> mmif.Mmif:
@@ -92,24 +75,32 @@ def describe_argparser():
92
75
 
93
76
 
94
77
  def prep_argparser(**kwargs):
95
- parser = argparse.ArgumentParser(description=describe_argparser()[1], formatter_class=argparse.RawDescriptionHelpFormatter, **kwargs)
96
- parser.add_argument("mmif_file", nargs=1, help="Path to the input MMIF file, or '-' to read from stdin.")
97
- parser.add_argument("-o", '--output', default=None, metavar="PATH", help="Path to the rewound MMIF output file. When not given, the rewound MMIF is printed to stdout.")
98
- parser.add_argument("-p", '--pretty', action='store_true', help="Pretty-print rewound MMIF. True by default")
99
- parser.add_argument("-n", '--number', default="0", type=is_valid_choice, help="Number of views to rewind (default: interactive mode)")
100
- parser.add_argument("-m", '--mode', choices=['app', 'view'], default='view', help="Number of views to rewind (default: interactive mode)")
78
+ parser = argparse.ArgumentParser(description=describe_argparser()[1],
79
+ formatter_class=argparse.RawDescriptionHelpFormatter, **kwargs)
80
+ parser.add_argument("mmif_file",
81
+ help="Path to the input MMIF file, or '-' to read from stdin.")
82
+ parser.add_argument("-o", '--output', default=None, metavar="PATH",
83
+ help="Path to the rewound MMIF output file. When not given, the rewound is printed to stdout.")
84
+ parser.add_argument("-p", '--pretty', action='store_true',
85
+ help="Pretty-print rewound MMIF")
86
+ parser.add_argument("-n", '--number', default="0", type=int,
87
+ help="Number of views or apps to rewind, must be a positive integer. "
88
+ "If 0, the user will be prompted to choose. (default: 0)")
89
+ parser.add_argument("-m", '--mode', choices=['app', 'view'], default='view',
90
+ help="Choose to rewind by number of views or number of producer apps. (default: view)")
101
91
  return parser
102
92
 
103
93
 
104
94
  def main(args):
105
- mmif_obj = mmif.Mmif(sys.stdin) if args.mmif_file[0] == '-' else mmif.Mmif(open(args.mmif_file[0]).read())
95
+ mmif_obj = mmif.Mmif(str(sys.stdin)) if args.mmif_file[0] == '-' else mmif.Mmif(open(args.mmif_file).read())
106
96
 
107
- if args.number == 0: # If user doesn't know how many views to rewind, give them choices.
108
- choice = user_choice(mmif_obj)
97
+ if args.number == 0: # If user doesn't know how many views to rewind, give them choices.
98
+ choice = prompt_user(mmif_obj)
109
99
  else:
110
100
  choice = args.number
101
+ if not isinstance(choice, int) or choice <= 0:
102
+ raise ValueError(f"Only can rewind by a positive number of views. Got {choice}.")
111
103
 
112
-
113
104
  if args.output:
114
105
  # Check if the same file name exist in the path and avoid overwriting.
115
106
  output_fp = P(args.output)
@@ -132,4 +123,3 @@ if __name__ == "__main__":
132
123
  parser = prep_argparser()
133
124
  args = parser.parse_args()
134
125
  main(args)
135
-
@@ -0,0 +1 @@
1
+ __version__ = "1.1.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clams-python
3
- Version: 1.1.1
3
+ Version: 1.1.2
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.8
17
+ Requires-Dist: mmif-python==1.0.9
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.8
1
+ mmif-python==1.0.9
2
2
  Flask>=2
3
3
  Flask-RESTful>=0.3.9
4
4
  gunicorn>=20
@@ -1,4 +1,4 @@
1
- mmif-python==1.0.8
1
+ mmif-python==1.0.9
2
2
 
3
3
  Flask>=2
4
4
  Flask-RESTful>=0.3.9
@@ -247,7 +247,12 @@ class TestClamsApp(unittest.TestCase):
247
247
  self.app.metadata.add_parameter('param3', 'third_param', 'boolean', default='f')
248
248
  self.app.metadata.add_parameter('param4', 'fourth_param', 'integer', default='1', choices="1 2 3".split())
249
249
  self.app.metadata.add_parameter('param5', 'fifth_param', 'number', default='0.5')
250
- conf = self.app._refine_params(param1='okay', non_parameter='should be ignored')
250
+ dummy_params = {'param1': 'okay', 'non_parameter': 'should be ignored'}
251
+ conf = self.app._refine_params(**dummy_params)
252
+ # should not refine what's already refined
253
+ double_refine = self.app._refine_params(**conf)
254
+ self.assertTrue(clams.ClamsApp._RAW_PARAMS_KEY in double_refine)
255
+ self.assertEqual(double_refine, conf)
251
256
  conf.pop(clams.ClamsApp._RAW_PARAMS_KEY, None)
252
257
  self.assertEqual(len(conf), 5) # 1 from `param1`, 4 from default value
253
258
  self.assertFalse('non_parameter' in conf)
@@ -1 +0,0 @@
1
- 1.1.1
@@ -1 +0,0 @@
1
- __version__ = "1.1.1"
File without changes
File without changes
File without changes
File without changes
File without changes