clams-python 0.6.3__tar.gz → 1.0.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 (40) hide show
  1. {clams-python-0.6.3/clams_python.egg-info → clams-python-1.0.0}/PKG-INFO +1 -1
  2. clams-python-1.0.0/VERSION +1 -0
  3. {clams-python-0.6.3 → clams-python-1.0.0}/clams/__init__.py +7 -5
  4. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/__init__.py +58 -27
  5. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/README.md +11 -5
  6. {clams-python-0.6.3 → clams-python-1.0.0}/clams/source/__init__.py +13 -3
  7. clams-python-1.0.0/clams/ver/__init__.py +1 -0
  8. {clams-python-0.6.3 → clams-python-1.0.0/clams_python.egg-info}/PKG-INFO +1 -1
  9. {clams-python-0.6.3 → clams-python-1.0.0}/clams_python.egg-info/SOURCES.txt +5 -6
  10. {clams-python-0.6.3 → clams-python-1.0.0}/clams_python.egg-info/requires.txt +1 -1
  11. {clams-python-0.6.3 → clams-python-1.0.0}/requirements.txt +1 -1
  12. clams-python-0.6.3/VERSION +0 -1
  13. clams-python-0.6.3/clams/develop/templates/app/CLAMS-generic-readme.md +0 -69
  14. clams-python-0.6.3/clams/ver/__init__.py +0 -1
  15. {clams-python-0.6.3 → clams-python-1.0.0}/LICENSE +0 -0
  16. {clams-python-0.6.3 → clams-python-1.0.0}/MANIFEST.in +0 -0
  17. {clams-python-0.6.3 → clams-python-1.0.0}/README.md +0 -0
  18. {clams-python-0.6.3 → clams-python-1.0.0}/clams/app/__init__.py +0 -0
  19. {clams-python-0.6.3 → clams-python-1.0.0}/clams/appmetadata/__init__.py +0 -0
  20. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/.dockerignore +0 -0
  21. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/.gitignore +0 -0
  22. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/Containerfile +0 -0
  23. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/LICENSE +0 -0
  24. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/app.py +0 -0
  25. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/metadata.py +0 -0
  26. {clams-python-0.6.3 → clams-python-1.0.0}/clams/develop/templates/app/requirements.txt +0 -0
  27. {clams-python-0.6.3/clams/develop/templates/github → clams-python-1.0.0/clams/develop/templates/gha}/README.md +0 -0
  28. {clams-python-0.6.3/clams/develop/templates/github → clams-python-1.0.0/clams/develop/templates/gha}/workflows/issue-apps-project.yml +0 -0
  29. {clams-python-0.6.3/clams/develop/templates/github → clams-python-1.0.0/clams/develop/templates/gha}/workflows/issue-assign.yml +0 -0
  30. {clams-python-0.6.3/clams/develop/templates/github → clams-python-1.0.0/clams/develop/templates/gha}/workflows/issue-close.yml +0 -0
  31. {clams-python-0.6.3/clams/develop/templates/github → clams-python-1.0.0/clams/develop/templates/gha}/workflows/publish.yml +0 -0
  32. {clams-python-0.6.3 → clams-python-1.0.0}/clams/restify/__init__.py +0 -0
  33. {clams-python-0.6.3 → clams-python-1.0.0}/clams/serve/__init__.py +0 -0
  34. {clams-python-0.6.3 → clams-python-1.0.0}/clams_python.egg-info/dependency_links.txt +0 -0
  35. {clams-python-0.6.3 → clams-python-1.0.0}/clams_python.egg-info/entry_points.txt +0 -0
  36. {clams-python-0.6.3 → clams-python-1.0.0}/clams_python.egg-info/top_level.txt +0 -0
  37. {clams-python-0.6.3 → clams-python-1.0.0}/setup.cfg +0 -0
  38. {clams-python-0.6.3 → clams-python-1.0.0}/setup.py +0 -0
  39. {clams-python-0.6.3 → clams-python-1.0.0}/tests/test_clamsapp.py +0 -0
  40. {clams-python-0.6.3 → clams-python-1.0.0}/tests/test_clamscli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clams-python
3
- Version: 0.6.3
3
+ Version: 1.0.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
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -2,17 +2,15 @@ import sys
2
2
 
3
3
  from mmif import __specver__
4
4
 
5
- from clams import source
6
5
  from clams import develop
6
+ from clams import source
7
7
  from clams.app import *
8
8
  from clams.app import __all__ as app_all
9
9
  from clams.appmetadata import AppMetadata
10
10
  from clams.restify import Restifier
11
- from clams.source import WorkflowSource
12
- from clams.develop import CookieCutter
13
11
  from clams.ver import __version__
14
12
 
15
- __all__ = [AppMetadata, Restifier, WorkflowSource] + app_all
13
+ __all__ = [AppMetadata, Restifier] + app_all
16
14
  version_template = "{} (based on MMIF spec: {})"
17
15
 
18
16
 
@@ -28,7 +26,11 @@ def prep_argparser():
28
26
  for subcmd_module in [source, develop]:
29
27
  subcmd_name = subcmd_module.__name__.rsplit('.')[-1]
30
28
  subcmd_parser = subcmd_module.prep_argparser(add_help=False)
31
- subparsers.add_parser(subcmd_name, parents=[subcmd_parser], help=subcmd_module.prep_argparser.__doc__)
29
+ subparsers.add_parser(subcmd_name, parents=[subcmd_parser],
30
+ help=subcmd_module.describe_argparser()[0],
31
+ description=subcmd_module.describe_argparser()[1],
32
+ formatter_class=argparse.RawDescriptionHelpFormatter,
33
+ )
32
34
  return parser
33
35
 
34
36
 
@@ -3,30 +3,56 @@ import pathlib
3
3
  import re
4
4
  import shutil
5
5
  from string import Template
6
+ from typing import List
6
7
 
7
8
  import clams
8
9
 
10
+ available_recipes = {
11
+ 'app': {
12
+ 'description': 'Skeleton code for a CLAMS app',
13
+ 'sourcedir': 'app',
14
+ 'targetdir': '.',
15
+ },
16
+ 'gha': {
17
+ 'description': 'GtiHub Actions workflow files specific to `clamsproject` GitHub organization',
18
+ 'sourcedir': 'gha',
19
+ 'targetdir': '.github',
20
+ }
21
+ }
22
+
9
23
 
10
24
  class CookieCutter(object):
11
25
 
12
- def __init__(self, name:str, outdir:str, ghactions:bool=True):
26
+ def __init__(self, name: str, outdir: str, recipes: List[str]):
13
27
  self.rawname = name
14
28
  self.name_tokens = self.tokenize_rawname()
15
29
  self.ourdir = pathlib.Path(outdir)
16
- self.copy_gha = ghactions
30
+ if recipes:
31
+ self.recipes = recipes
32
+ else:
33
+ self.recipes = available_recipes.keys()
17
34
 
18
35
  def tokenize_rawname(self):
19
36
  word_pat = re.compile('[A-Z][a-z]+|[0-9A-Z]+(?=[A-Z][a-z])|[0-9A-Z]{2,}|[a-z0-9]{2,}|[a-zA-Z0-9]')
20
37
  words = [m.group(0).lower() for m in word_pat.finditer(self.rawname)]
21
- if words[0] == 'app':
22
- words.pop(0)
23
- if words[-1] == 'app':
24
- words.pop()
38
+ if len(words) > 1:
39
+ if words[0] == 'app':
40
+ words.pop(0)
41
+ if words[-1] == 'app':
42
+ words.pop()
25
43
  return words
26
44
 
27
45
  def bake(self):
28
- src_dir = pathlib.Path(__file__).parent / 'templates' / 'app'
29
- dst_dir = self.ourdir / self.rawname
46
+ print(f"Baking {self.recipes}")
47
+ for recipe in self.recipes:
48
+ src_dir = pathlib.Path(__file__).parent / 'templates' / available_recipes[recipe]['sourcedir']
49
+ dst_dir = self.ourdir / self.rawname / available_recipes[recipe]['targetdir']
50
+ if recipe == 'app':
51
+ self.bake_app(src_dir, dst_dir)
52
+ if recipe == 'gha':
53
+ self.bake_gha(src_dir, dst_dir)
54
+
55
+ def bake_app(self, src_dir, dst_dir):
30
56
  excludes = {'__init__.py'}
31
57
  caps = [t.capitalize() for t in self.name_tokens]
32
58
  templating_vars = {
@@ -46,30 +72,35 @@ class CookieCutter(object):
46
72
  tmpl_to_compile = Template(in_f.read())
47
73
  compiled = tmpl_to_compile.safe_substitute(templating_vars)
48
74
  out_f.write(compiled)
49
- if self.copy_gha:
50
- src_dir = pathlib.Path(__file__).parent / 'templates' / 'github'
51
- dst_dir = dst_dir / '.github'
52
- shutil.copytree(src_dir, dst_dir)
75
+ print(f"App skeleton code is copied to {self.rawname}")
76
+ print(f" Checkout {self.rawname}/README.md for the next steps!")
77
+
78
+ def bake_gha(self, src_dir, dst_dir):
79
+ shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True)
80
+ print(f"GitHub Actions workflow files are copied to {self.rawname}/.github")
81
+ print(f" Checkout {self.rawname}/.github/README.md for how they work!")
53
82
 
54
83
 
55
- def prep_argparser(**kwargs):
84
+ def describe_argparser():
56
85
  """
57
- provides CLI to create a skeleton code for app development.
86
+ returns two strings: one-line description of the argparser, and addition material,
87
+ which will be shown in `clams --help` and `clams <subcmd> --help`, respectively.
58
88
  """
59
- parser = argparse.ArgumentParser(**kwargs)
89
+ oneliner = 'provides CLI to create a skeleton code for app development'
90
+ additional = "Available recipes:\n"
91
+ for k, v in available_recipes.items():
92
+ additional += f" - {k}: {v['description']}\n"
93
+ return oneliner, oneliner + '\n\n' + additional
94
+
95
+
96
+ def prep_argparser(**kwargs):
97
+ parser = argparse.ArgumentParser(description=describe_argparser()[1], formatter_class=argparse.RawDescriptionHelpFormatter, **kwargs)
60
98
  parser.add_argument(
61
- '-r', '--recipe',
99
+ '-r', '--recipes',
62
100
  action='store',
63
- default='app',
64
- choices=['app'],
65
- help="Pick a recipe to use. Currently `app` is the only option, hence there's no need to use the flag at all."
66
- )
67
- parser.add_argument(
68
- '--no-github-actions',
69
- action='store_true',
70
- help='The cookiecutter by default assumes that the app codebase will be hosted on `github.com/clamsproejct`, '
71
- 'and add pre-shipped github actions for the `clamsproject` organization setup to the skeleton codebase. '
72
- 'Use this options to disable this behavior.'
101
+ nargs='+',
102
+ default=[],
103
+ help=f"Pick recipes to bake. DEFAULT: {list(available_recipes.keys())}"
73
104
  )
74
105
  parser.add_argument(
75
106
  '-n', '--name',
@@ -97,7 +128,7 @@ def prep_argparser(**kwargs):
97
128
 
98
129
 
99
130
  def main(args):
100
- cutter = CookieCutter(name=args.name, outdir=args.parent_dir, ghactions=not args.no_github_actions)
131
+ cutter = CookieCutter(name=args.name, outdir=args.parent_dir, recipes=args.recipes)
101
132
  cutter.bake()
102
133
 
103
134
  if __name__ == '__main__':
@@ -7,21 +7,27 @@ This skeleton code is a scaffolding for Python-based CLAMS app development. Spec
7
7
 
8
8
  1. `app.py` and `metadata.py` to write the app
9
9
  1. `requirements.txt` to specify python dependencies
10
- 1. `.gitignore` file listing common ignored files
11
10
  1. `Containerfile` to containerize the app and specify system dependencies
11
+ 1. `.gitignore` and `.dorckrignore` files listing commonly ignored files
12
12
  1. an empty `LICENSE` file to replace with an actual license information of the app
13
13
  1. `CLAMS-generic-readme.md` file with basic instructions of app installation and execution
14
14
  1. This `README.md` file for additional information not specified in the generic readme file.
15
- 1. (optional) some GH actions workflow for issue/bug-report management
16
- 1. (optional) a GH actions workflow to build and upload app images upon any push of a git tag
15
+ 1. A number of GitHub Actions workflows for issue/bug-report management
16
+ 1. A GHA workflow to publish app images upon any push of a git tag
17
+ * **NOTE**: All GHA workflows included are designed to only work in repositories under `clamsproject` organization.
17
18
 
18
- Use the following section to document any additional information specific to this app. If your app works significantly
19
- different from what's described in the generic readme file, be as specific as possible.
19
+ Before pushing your first commit, please make sure to delete this section of the document.
20
+
21
+ Then use the following section to document any additional information specific to this app. If your app works significantly different from what's described in the generic readme file, be as specific as possible.
20
22
 
21
23
  ---
22
24
 
23
25
  ## User instruction
24
26
 
27
+ General user instruction for CLAMS apps is available at [CLAMS Apps documentation](https://apps.clams.ai/clamsapp/).
28
+
29
+ Below is a list of additional information specific to this app.
30
+
25
31
  ### System requirments
26
32
 
27
33
  (Any system-level software required to run this app)
@@ -2,6 +2,7 @@ import argparse
2
2
  import itertools
3
3
  import json
4
4
  import sys
5
+ import textwrap
5
6
  from os import path
6
7
  from typing import Union, Generator, List, Optional, Iterable
7
8
 
@@ -215,11 +216,20 @@ def generate_source_mmif(documents, prefix=None, **ignored):
215
216
  return pl.produce().serialize(pretty=True)
216
217
 
217
218
 
218
- def prep_argparser(**kwargs):
219
+ def describe_argparser():
219
220
  """
220
- provides CLI to create a "source" MMIF json. A source MMIF is a MMIF with a list of source documents but empty views. It can be used as a starting point for a CLAMS workflow.
221
+ returns two strings: one-line description of the argparser, and addition material,
222
+ which will be shown in `clams --help` and `clams <subcmd> --help`, respectively.
221
223
  """
222
- parser = argparse.ArgumentParser(**kwargs)
224
+ oneliner = 'provides CLI to create a "source" MMIF json.'
225
+ additional = textwrap.dedent("""
226
+ A source MMIF is a MMIF with a list of source documents but empty views.
227
+ It can be used as a starting point for a CLAMS workflow. """)
228
+ return oneliner, oneliner + '\n\n' + additional
229
+
230
+
231
+ def prep_argparser(**kwargs):
232
+ parser = argparse.ArgumentParser(description=describe_argparser()[1], formatter_class=argparse.RawDescriptionHelpFormatter, **kwargs)
223
233
  parser.add_argument(
224
234
  'documents',
225
235
  default=None,
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clams-python
3
- Version: 0.6.3
3
+ Version: 1.0.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
@@ -10,18 +10,17 @@ clams/appmetadata/__init__.py
10
10
  clams/develop/__init__.py
11
11
  clams/develop/templates/app/.dockerignore
12
12
  clams/develop/templates/app/.gitignore
13
- clams/develop/templates/app/CLAMS-generic-readme.md
14
13
  clams/develop/templates/app/Containerfile
15
14
  clams/develop/templates/app/LICENSE
16
15
  clams/develop/templates/app/README.md
17
16
  clams/develop/templates/app/app.py
18
17
  clams/develop/templates/app/metadata.py
19
18
  clams/develop/templates/app/requirements.txt
20
- clams/develop/templates/github/README.md
21
- clams/develop/templates/github/workflows/issue-apps-project.yml
22
- clams/develop/templates/github/workflows/issue-assign.yml
23
- clams/develop/templates/github/workflows/issue-close.yml
24
- clams/develop/templates/github/workflows/publish.yml
19
+ clams/develop/templates/gha/README.md
20
+ clams/develop/templates/gha/workflows/issue-apps-project.yml
21
+ clams/develop/templates/gha/workflows/issue-assign.yml
22
+ clams/develop/templates/gha/workflows/issue-close.yml
23
+ clams/develop/templates/gha/workflows/publish.yml
25
24
  clams/restify/__init__.py
26
25
  clams/serve/__init__.py
27
26
  clams/source/__init__.py
@@ -1,4 +1,4 @@
1
- mmif-python==0.5.2
1
+ mmif-python==1.0.0
2
2
  Flask>=2
3
3
  Flask-RESTful>=0.3.9
4
4
  gunicorn>=20
@@ -1,4 +1,4 @@
1
- mmif-python==0.5.2
1
+ mmif-python==1.0.0
2
2
 
3
3
  Flask>=2
4
4
  Flask-RESTful>=0.3.9
@@ -1 +0,0 @@
1
- 0.6.3
@@ -1,69 +0,0 @@
1
- # CLAMS App
2
-
3
- This document provides general instructions for installing and using CLAMS apps.
4
- App developers may provide additional information specific to their app,
5
- hence it's advised also to look up the app website (or code repository) to get the additional information.
6
-
7
- ## Requirements
8
-
9
- Generally, an CLAMS app requires
10
-
11
- - Python3 with the `clams-python` module installed; to run the app locally.
12
- - `docker` or `podman`; to run the app in a container (as an HTTP server).
13
- - An HTTP client utility (such as `curl`); to invoke and execute analysis.
14
-
15
- For Python dependencies, usually apps come with `requirements.txt` files that list up the Python library.
16
- However, there could be other non-Python software/library that are required by the app.
17
-
18
- ## Installation
19
-
20
- Currently, CLAMS apps available on the CLAMS app-directory are all open-source projects and are distributed as
21
-
22
- 1. source code downloadable from code repository
23
- 2. pre-built container image
24
-
25
- Please visit [the app-directory](https://github.com/clamsproject/clams-apps) to see which apps are available and where you can download them.
26
-
27
- In most cases, you can "install" a CLAMS app by either
28
- 1. downloading source code from the app code repository and manually building a container image
29
- 2. downloading pre-built container image directly
30
-
31
- ## Building container image
32
-
33
- From the project directory, run the following in your terminal to build an image from the included container specification file.
34
-
35
- (Assuming you are using `docker` as your container manager)
36
-
37
- ```bash
38
- docker build . -f Containerfile -t <app_name>
39
- ```
40
-
41
- Alternatively, the app maybe already be available on a container registry.
42
-
43
- ``` bash
44
- docker pull <app_name>
45
- ```
46
-
47
- ## Running the image
48
-
49
- Then to create a container using that image, run:
50
-
51
- ```bash
52
- docker run -v /path/to/data/directory:/data -p <port>:5000 <app_name>
53
- ```
54
-
55
- where `/path/to/data/directory` is the local location of your media files or MMIF objects and <port> is the *host* port number you want your container to be listening to.
56
- The HTTP inside the container will be listening to 5000 by default.
57
-
58
- ## Invoking the app
59
- Once the app is running as an HTTP server, to invoke the app and get automatic annotations, simply send a POST request to the app with a MMIF input as request body.
60
-
61
- MMIF input files can be obtained from outputs of other CLAMS apps, or you can create an empty MMIF only with source media locations using `clams source` command. See the help message for a more detailed instructions.
62
- (Make sure you have installed [`clams-python` package](https://pypi.org/project/clams-python/) version from PyPI.)
63
-
64
- ```bash
65
- pip install clams-python
66
- clams source --help
67
- ```
68
-
69
-
@@ -1 +0,0 @@
1
- __version__ = "0.6.3"
File without changes
File without changes
File without changes
File without changes
File without changes