Skip to content

Commit f2869b0

Browse files
authored
Merge pull request #343 from clamsproject/develop
releasing 1.2.1
2 parents f6f5eac + 3a8cb2c commit f2869b0

File tree

15 files changed

+826
-310
lines changed

15 files changed

+826
-310
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ documentation/_build/
8484
/VERSION
8585
_issues
8686

87+
documentation/cli_help.rst
Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
mmif.utils package
22
==================
33

4-
Package containing utility modules for handling different types of source
5-
documents, and general implementation of common data structures and
4+
Package containing utility modules for handling different types of source
5+
documents, and general implementation of common data structures and
66
algorithms.
77

8+
Submodules
9+
----------
10+
811
``video_document_helper`` module
9-
----------------------------------------
12+
--------------------------------
1013

1114
.. automodule:: mmif.utils.video_document_helper
1215
:members:
1316
:undoc-members:
1417
:show-inheritance:
1518

1619
``text_document_helper`` module
17-
---------------------------------
20+
-------------------------------
1821

19-
.. automodule:: mmif.utils.sequence_helper
22+
.. automodule:: mmif.utils.text_document_helper
2023
:members:
2124
:undoc-members:
2225
:show-inheritance:
2326

24-
``sequence_helper`` module
25-
---------------------------------
27+
``timeunit_helper`` module
28+
-------------------------------
2629

27-
.. automodule:: mmif.utils.sequence_helper
30+
.. automodule:: mmif.utils.timeunit_helper
2831
:members:
2932
:undoc-members:
3033
:show-inheritance:
3134

3235
``sequence_helper`` module
33-
---------------------------------
36+
--------------------------
3437

3538
.. automodule:: mmif.utils.sequence_helper
3639
:members:
3740
:undoc-members:
3841
:show-inheritance:
3942

43+
``workflow_helper`` module
44+
--------------------------
45+
46+
.. automodule:: mmif.utils.workflow_helper
47+
:members:
48+
:undoc-members:
49+
:show-inheritance:

documentation/cli.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. _cli:
2+
3+
``mmif`` shell command
4+
======================
5+
6+
``mmif-python`` comes with a command line interface (CLI) that allows you to handle MMIF files. Many of these commands are designed to handle MMIF files in the context of CLAMS workflows.
7+
8+
The CLI is installed as ``mmif`` shell command. To see the available commands, run
9+
10+
.. code-block:: bash
11+
12+
mmif --help
13+
14+
.. contents::
15+
:local:
16+
:backlinks: none
17+
18+
The following documentation is automatically generated from the CLI help messages.
19+
20+
.. include:: cli_help.rst

documentation/conf.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

77
import datetime
8+
import textwrap
89

910
# -- Path setup --------------------------------------------------------------
1011

@@ -110,4 +111,40 @@ def linkcode_resolve(domain, info):
110111
# 1. sphinx-mv/main.py know current version of the library by git tag,
111112
# but conf.py has no way to know that...
112113
# 2. target-versions.csv file can be read once and used in the for loop
113-
# in sphinx-mv/main.py, but here it should be read in for each `docs` bulid.
114+
# ... (previous content)
115+
116+
def generate_cli_rst(app):
117+
import mmif
118+
from mmif import prep_argparser_and_subcmds, find_all_modules
119+
120+
# Generate main help
121+
os.environ['COLUMNS'] = '100'
122+
parser, subparsers = prep_argparser_and_subcmds()
123+
help_text = parser.format_help()
124+
125+
content = []
126+
127+
content.append('Main Command\n')
128+
content.append('------------\n\n')
129+
content.append('.. code-block:: text\n\n')
130+
content.append(textwrap.indent(help_text, ' '))
131+
content.append('\n\n')
132+
133+
# Generate subcommand help
134+
for cli_module in find_all_modules('mmif.utils.cli'):
135+
cli_module_name = cli_module.__name__.rsplit('.')[-1]
136+
subparser = cli_module.prep_argparser(prog=f'mmif {cli_module_name}')
137+
sub_help = subparser.format_help()
138+
139+
content.append(f'{cli_module_name}\n')
140+
content.append('-' * len(cli_module_name) + '\n\n')
141+
content.append('.. code-block:: text\n\n')
142+
content.append(textwrap.indent(sub_help, ' '))
143+
content.append('\n\n')
144+
145+
with open(proj_root_dir / 'documentation' / 'cli_help.rst', 'w') as f:
146+
f.write(''.join(content))
147+
148+
149+
def setup(app):
150+
app.connect('builder-inited', generate_cli_rst)

documentation/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Welcome to mmif-python's documentation!
88
:caption: Contents
99

1010
introduction
11+
cli
1112
plugins
1213
target-versions
1314

documentation/introduction.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,9 @@ To get subcomponents, you can use various getters implemented in subclasses. For
8787
8888
For a full list of available helper methods, please refer to :ref:`the API documentation <apidoc>`.
8989

90+
MMIF usage in CLAMS Workflows
91+
-----------------------------
92+
93+
In the context of CLAMS, a **Workflow** refers to the sequence of CLAMS applications that have been executed to generate the views and annotations within a MMIF file.
94+
95+
When using the ``mmif-python`` SDK, a unique identifier for a workflow (``workflowId``) is calculated based on the applications involved. This identifier is constructed by concatenating the application name, version, and a hash of the runtime parameters for each step in the sequence. This ensures that the identifier uniquely represents not just the apps used, but their specific configurations, aiding in reproducibility.

mmif/serialize/annotation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
The :mod:`annotation` module contains the classes used to represent a
33
MMIF annotation as a live Python object.
44
5-
In MMIF, annotations are created by apps in a pipeline as a part
5+
In MMIF, annotations are created by apps in a workflow as a part
66
of a view. For documentation on how views are represented, see
77
:mod:`mmif.serialize.view`.
88
"""

mmif/serialize/mmif.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ def get_alignments(self, at_type1: Union[str, ThingTypesBase], at_type2: Union[s
635635
def get_views_for_document(self, doc_id: str) -> List[View]:
636636
"""
637637
Returns the list of all views that have annotations anchored on a particular document.
638-
Note that when the document is inside a view (generated during the pipeline's running),
638+
Note that when the document is inside a view (generated during the workflow's running),
639639
doc_id must be prefixed with the view_id.
640640
"""
641641
views = []

mmif/serialize/view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
The :mod:`view` module contains the classes used to represent a MMIF view
33
as a live Python object.
44
5-
In MMIF, views are created by apps in a pipeline that are annotating
5+
In MMIF, views are created by apps in a workflow that are annotating
66
data that was previously present in the MMIF file.
77
88
The :class:`View` class is a high-level container that provides convenient

0 commit comments

Comments
 (0)