cellgraph 0.1.0__py3-none-any.whl
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.
- cellgraph/__init__.py +142 -0
- cellgraph/analysis.py +1013 -0
- cellgraph/core.py +87 -0
- cellgraph/diagnostics.py +26 -0
- cellgraph/effects.py +127 -0
- cellgraph/grammar.py +144 -0
- cellgraph/keys.py +420 -0
- cellgraph/languages.py +96 -0
- cellgraph/plan.py +34 -0
- cellgraph/py.typed +0 -0
- cellgraph/python.py +672 -0
- cellgraph/vocabulary.py +263 -0
- cellgraph-0.1.0.dist-info/METADATA +63 -0
- cellgraph-0.1.0.dist-info/RECORD +16 -0
- cellgraph-0.1.0.dist-info/WHEEL +4 -0
- cellgraph-0.1.0.dist-info/licenses/LICENSE +201 -0
cellgraph/vocabulary.py
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"""Annotations and the vocabulary a host composes from them (design 4).
|
|
2
|
+
|
|
3
|
+
An annotation declares its key (and any extra keys it reads), a parser from its
|
|
4
|
+
directive lines to a value, its effects from the closed set in ``effects``, whether
|
|
5
|
+
it is in the definition key, an encoder when its value is not already canonical,
|
|
6
|
+
and an optional validator. The package applies the effects and never interprets
|
|
7
|
+
an annotation beyond them: one with no effects that is not in the key is metadata,
|
|
8
|
+
available to the host as ``cell.annotations[key]``.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
|
14
|
+
from dataclasses import dataclass, field, replace
|
|
15
|
+
from typing import TYPE_CHECKING, Any
|
|
16
|
+
|
|
17
|
+
from cellgraph.diagnostics import Diagnostic
|
|
18
|
+
from cellgraph.effects import Effect
|
|
19
|
+
from cellgraph.grammar import GRAMMAR, Directive, Grammar
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from cellgraph.analysis import Cell
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AnnotationError(ValueError):
|
|
26
|
+
"""A directive that cannot be read as written.
|
|
27
|
+
|
|
28
|
+
Raised by a parser, an encoder or a validator. It becomes an error diagnostic,
|
|
29
|
+
and the cell is not plannable. ``code`` defaults to ``<key>_unreadable``.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, message: str, *, code: str | None = None, line: int | None = None):
|
|
33
|
+
super().__init__(message)
|
|
34
|
+
self.code = code
|
|
35
|
+
self.line = line
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class Partial:
|
|
40
|
+
"""What a parser returns when part of an annotation reads: the value, and the errors.
|
|
41
|
+
|
|
42
|
+
The annotation is present with ``value`` (its effects and key field apply) and
|
|
43
|
+
each error becomes a diagnostic, so the cell is not plannable. For lines that
|
|
44
|
+
cannot be read beside lines that can, as Strata keeps the readable ones.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
value: Any
|
|
48
|
+
errors: tuple[AnnotationError, ...]
|
|
49
|
+
|
|
50
|
+
def __init__(self, value: Any, errors: Iterable[AnnotationError]) -> None:
|
|
51
|
+
object.__setattr__(self, "value", value)
|
|
52
|
+
object.__setattr__(self, "errors", tuple(errors))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass(frozen=True)
|
|
56
|
+
class ValidationContext:
|
|
57
|
+
"""What a validator sees: the cell, its names after effects, and the host's context."""
|
|
58
|
+
|
|
59
|
+
cell: Cell
|
|
60
|
+
defines: tuple[str, ...]
|
|
61
|
+
references: tuple[str, ...]
|
|
62
|
+
host: Any = None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
Parser = Callable[[list[Directive]], Any]
|
|
66
|
+
Validator = Callable[[Any, ValidationContext], Iterable[Diagnostic]]
|
|
67
|
+
CellEffects = Callable[[Mapping[str, Any], Mapping[str, Any]], Iterable[Effect]]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
_OFF = frozenset({"off", "false", "no", "0"})
|
|
71
|
+
_FLAG_VALUES = frozenset({"", "on", "off", "true", "false", "yes", "no", "1", "0"})
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def scalar(convert: Callable[[str], Any] = str) -> Parser:
|
|
75
|
+
"""One value; the last directive wins. An empty value or a failed ``convert`` is an error."""
|
|
76
|
+
|
|
77
|
+
def parse(directives: list[Directive]) -> Any:
|
|
78
|
+
last = directives[-1]
|
|
79
|
+
if not last.value:
|
|
80
|
+
raise AnnotationError(f"`@{last.key}` needs a value", line=last.line)
|
|
81
|
+
try:
|
|
82
|
+
return convert(last.value)
|
|
83
|
+
except (TypeError, ValueError) as exc:
|
|
84
|
+
raise AnnotationError(
|
|
85
|
+
f"`@{last.key} {last.value}` could not be read: {exc}", line=last.line
|
|
86
|
+
) from exc
|
|
87
|
+
|
|
88
|
+
return parse
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def flag() -> Parser:
|
|
92
|
+
"""``# @key`` or ``# @key on|off|true|false|yes|no|1|0``; the last directive wins."""
|
|
93
|
+
|
|
94
|
+
def parse(directives: list[Directive]) -> bool:
|
|
95
|
+
last = directives[-1]
|
|
96
|
+
if last.value.lower() not in _FLAG_VALUES:
|
|
97
|
+
raise AnnotationError(
|
|
98
|
+
f"`@{last.key} {last.value}`: expected nothing, or one of on, off, true, "
|
|
99
|
+
"false, yes, no, 1, 0",
|
|
100
|
+
line=last.line,
|
|
101
|
+
)
|
|
102
|
+
return last.value.strip().lower() not in _OFF
|
|
103
|
+
|
|
104
|
+
return parse
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def stacked(item: Callable[[Directive], Any]) -> Parser:
|
|
108
|
+
"""One value per directive line, in source order; the lines may repeat."""
|
|
109
|
+
|
|
110
|
+
def parse(directives: list[Directive]) -> list[Any]:
|
|
111
|
+
return [item(directive) for directive in directives]
|
|
112
|
+
|
|
113
|
+
return mark_stacked(parse)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def mark_stacked(parse: Parser) -> Parser:
|
|
117
|
+
"""Mark *parse* as reading repeated lines, so ``set_directive`` refuses its key."""
|
|
118
|
+
setattr(parse, "stacked", True) # noqa: B010
|
|
119
|
+
return parse
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def is_stacked(parse: Parser) -> bool:
|
|
123
|
+
"""Whether *parse* reads repeated lines (``stacked``), which a single-line edit would drop."""
|
|
124
|
+
return bool(getattr(parse, "stacked", False))
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _default_parse(directives: list[Directive]) -> Any:
|
|
128
|
+
return scalar(str)(directives)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@dataclass(frozen=True)
|
|
132
|
+
class Annotation:
|
|
133
|
+
"""One annotation of a vocabulary.
|
|
134
|
+
|
|
135
|
+
- ``parse`` gets every directive of ``key`` and ``also_reads``, in source order.
|
|
136
|
+
- ``effects`` maps the parsed value to effects; it runs only when a directive is
|
|
137
|
+
present.
|
|
138
|
+
- ``in_key``: a present annotation adds one field, named ``key``, to the definition
|
|
139
|
+
key. The value is ``encode(value)``, or the value itself when it is canonical.
|
|
140
|
+
- ``validate`` gets the value and a ``ValidationContext`` and returns diagnostics.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
key: str
|
|
144
|
+
parse: Parser = _default_parse
|
|
145
|
+
effects: Callable[[Any], Iterable[Effect]] | None = None
|
|
146
|
+
in_key: bool = True
|
|
147
|
+
encode: Callable[[Any], Any] | None = None
|
|
148
|
+
validate: Validator | None = None
|
|
149
|
+
also_reads: tuple[str, ...] = ()
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def keys(self) -> tuple[str, ...]:
|
|
153
|
+
"""Every directive key this annotation reads."""
|
|
154
|
+
return (self.key, *self.also_reads)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@dataclass(frozen=True)
|
|
158
|
+
class Vocabulary:
|
|
159
|
+
"""A set of annotations with distinct keys, and an optional per-cell host hook.
|
|
160
|
+
|
|
161
|
+
``cell_effects(meta, parsed)`` is called for every cell, with the host's ``meta``
|
|
162
|
+
and the parsed value of each present annotation. It returns effects that come
|
|
163
|
+
from host configuration rather than directives; they go through the same phases
|
|
164
|
+
and conflict rules.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
annotations: tuple[Annotation, ...] = ()
|
|
168
|
+
cell_effects: CellEffects | None = None
|
|
169
|
+
grammar: Grammar = field(default=GRAMMAR, compare=False)
|
|
170
|
+
|
|
171
|
+
def __init__(
|
|
172
|
+
self,
|
|
173
|
+
annotations: Sequence[Annotation] = (),
|
|
174
|
+
cell_effects: CellEffects | None = None,
|
|
175
|
+
grammar: Grammar = GRAMMAR,
|
|
176
|
+
) -> None:
|
|
177
|
+
seen: dict[str, str] = {}
|
|
178
|
+
for annotation in annotations:
|
|
179
|
+
for key in annotation.keys:
|
|
180
|
+
if key in seen:
|
|
181
|
+
raise ValueError(
|
|
182
|
+
f"directive key {key!r} is claimed by both @{seen[key]} and "
|
|
183
|
+
f"@{annotation.key}"
|
|
184
|
+
)
|
|
185
|
+
seen[key] = annotation.key
|
|
186
|
+
object.__setattr__(self, "annotations", tuple(annotations))
|
|
187
|
+
object.__setattr__(self, "cell_effects", cell_effects)
|
|
188
|
+
object.__setattr__(self, "grammar", grammar)
|
|
189
|
+
|
|
190
|
+
@classmethod
|
|
191
|
+
def core(cls) -> Vocabulary:
|
|
192
|
+
"""``@name``, ``@after``, ``@nocache``, ``@variant`` and ``@per_variant`` (design 6)."""
|
|
193
|
+
from cellgraph.core import core_annotations
|
|
194
|
+
|
|
195
|
+
return cls(core_annotations())
|
|
196
|
+
|
|
197
|
+
def __or__(self, other: Vocabulary) -> Vocabulary:
|
|
198
|
+
"""Both vocabularies; a key in both is refused, so order never decides a result."""
|
|
199
|
+
hooks = [hook for hook in (self.cell_effects, other.cell_effects) if hook is not None]
|
|
200
|
+
combined: CellEffects | None
|
|
201
|
+
if len(hooks) == 2:
|
|
202
|
+
first, second = hooks
|
|
203
|
+
|
|
204
|
+
def combined(meta: Mapping[str, Any], parsed: Mapping[str, Any]) -> list[Effect]:
|
|
205
|
+
return [*first(meta, parsed), *second(meta, parsed)]
|
|
206
|
+
|
|
207
|
+
else:
|
|
208
|
+
combined = hooks[0] if hooks else None
|
|
209
|
+
return Vocabulary([*self.annotations, *other.annotations], cell_effects=combined)
|
|
210
|
+
|
|
211
|
+
def __iter__(self) -> Iterator[Annotation]:
|
|
212
|
+
return iter(self.annotations)
|
|
213
|
+
|
|
214
|
+
def __contains__(self, key: object) -> bool:
|
|
215
|
+
return any(annotation.key == key for annotation in self.annotations)
|
|
216
|
+
|
|
217
|
+
def __getitem__(self, key: str) -> Annotation:
|
|
218
|
+
for annotation in self.annotations:
|
|
219
|
+
if annotation.key == key:
|
|
220
|
+
return annotation
|
|
221
|
+
raise KeyError(key)
|
|
222
|
+
|
|
223
|
+
@property
|
|
224
|
+
def keys(self) -> frozenset[str]:
|
|
225
|
+
"""Every directive key the vocabulary reads, ``also_reads`` keys included."""
|
|
226
|
+
return frozenset(key for annotation in self.annotations for key in annotation.keys)
|
|
227
|
+
|
|
228
|
+
def owner(self, directive_key: str) -> Annotation | None:
|
|
229
|
+
"""The annotation that reads directives of *directive_key*, if any."""
|
|
230
|
+
for annotation in self.annotations:
|
|
231
|
+
if directive_key in annotation.keys:
|
|
232
|
+
return annotation
|
|
233
|
+
return None
|
|
234
|
+
|
|
235
|
+
def without(self, *keys: str) -> Vocabulary:
|
|
236
|
+
"""This vocabulary without the annotations named *keys*."""
|
|
237
|
+
missing = set(keys) - {a.key for a in self.annotations}
|
|
238
|
+
if missing:
|
|
239
|
+
raise KeyError(sorted(missing))
|
|
240
|
+
return Vocabulary(
|
|
241
|
+
[a for a in self.annotations if a.key not in keys],
|
|
242
|
+
cell_effects=self.cell_effects,
|
|
243
|
+
grammar=self.grammar,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
def replace(self, key: str, **changes: Any) -> Vocabulary:
|
|
247
|
+
"""This vocabulary with annotation *key* changed, e.g. given a validator."""
|
|
248
|
+
return Vocabulary(
|
|
249
|
+
[replace(a, **changes) if a.key == key else a for a in self.annotations],
|
|
250
|
+
cell_effects=self.cell_effects,
|
|
251
|
+
grammar=self.grammar,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
def set_directive(self, source: str, key: str, value: str) -> str:
|
|
255
|
+
"""*source* with one ``# @key value`` set; refused for a stacked annotation's key."""
|
|
256
|
+
owner = self.owner(key.lower())
|
|
257
|
+
if owner is not None and is_stacked(owner.parse):
|
|
258
|
+
raise ValueError(f"@{key} is repeatable; edit the cell source directly")
|
|
259
|
+
return self.grammar.set_directive(source, key, value)
|
|
260
|
+
|
|
261
|
+
def remove_directive(self, source: str, key: str) -> str:
|
|
262
|
+
"""*source* with every ``# @key`` directive removed from its leading block."""
|
|
263
|
+
return self.grammar.remove_directive(source, key)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cellgraph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The cell graph of a notebook or script: annotations with a host-supplied vocabulary, analysis, the DAG, and the keys that say whether a cell must run.
|
|
5
|
+
Author: Fangchen Li
|
|
6
|
+
Author-email: Fangchen Li <fangchen.li@outlook.com>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Project-URL: Homepage, https://github.com/bearing-research/cellgraph
|
|
17
|
+
Project-URL: Repository, https://github.com/bearing-research/cellgraph
|
|
18
|
+
Project-URL: Changelog, https://github.com/bearing-research/cellgraph/blob/main/CHANGELOG.md
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# cellgraph
|
|
22
|
+
|
|
23
|
+
The cell graph of a notebook or script. A cell is source with a leading
|
|
24
|
+
`# @key value` block; the set of annotations is the host's, composed from the
|
|
25
|
+
ten effects the package implements (binds, defines, reads, keeps, after, seeds,
|
|
26
|
+
member, fan-out, input, no-cache). `analyze` reads every cell's names and
|
|
27
|
+
annotations, applies their effects, wires the DAG, says which cells can be
|
|
28
|
+
planned and why the others cannot, and keys each cell: a definition key from its
|
|
29
|
+
normalized source and the annotations that change what it computes, and an
|
|
30
|
+
execution key from the outputs and external inputs the host looks up. The
|
|
31
|
+
package has no dependencies and runs nothing; the host executes, stores and
|
|
32
|
+
resolves. It was factored out of Strata's notebook, its first host, whose
|
|
33
|
+
formats it reproduces exactly under `legacy-1`.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install cellgraph
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
See [the API](https://github.com/bearing-research/cellgraph/blob/main/docs/api.md).
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import cellgraph as cg
|
|
43
|
+
|
|
44
|
+
vocab = cg.Vocabulary.core() | cg.Vocabulary(
|
|
45
|
+
[
|
|
46
|
+
cg.Annotation("gpu", parse=cg.scalar(str), in_key=False),
|
|
47
|
+
]
|
|
48
|
+
)
|
|
49
|
+
analysis = cg.analyze(
|
|
50
|
+
[cg.Cell("a", "x = 1\n"), cg.Cell("b", "# @gpu A100\ny = x + 1\n")],
|
|
51
|
+
vocab,
|
|
52
|
+
)
|
|
53
|
+
analysis.cells["b"].annotations["gpu"] # 'A100'
|
|
54
|
+
analysis.dag.topological_order # ['a', 'b']
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uv sync
|
|
61
|
+
uv run pytest
|
|
62
|
+
uv run pre-commit run --all-files
|
|
63
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
cellgraph/__init__.py,sha256=oFAXm37JLNTg4v0tpPCH3qpI-Ky1_JE4MMxuWmgfFqI,2820
|
|
2
|
+
cellgraph/analysis.py,sha256=qmilm5Lv-6tUIyKSoh0U7j5Bg4wNqOzWQMfD6z7eXe0,39213
|
|
3
|
+
cellgraph/core.py,sha256=frkhzoSuF66zGyx2p9MI0qEkNOS2ypCWJ1kZoNsfLnY,3157
|
|
4
|
+
cellgraph/diagnostics.py,sha256=8gGUODyP51q2NvDjdT1QQ0oAg3vELHVndgzaO5Q_41I,607
|
|
5
|
+
cellgraph/effects.py,sha256=BHEItUCN5bYUfrrewpO7lIkFgVeqoDMo4I_ACHbyo28,3018
|
|
6
|
+
cellgraph/grammar.py,sha256=WE8vJz7tmtVQ1aXF14Kvb5GX7voFxkFH2eTEo2oky0k,5403
|
|
7
|
+
cellgraph/keys.py,sha256=opDPkcM9qZZ2G6T4ZpE2BroBBoGi56VXd_U30_7hP38,15300
|
|
8
|
+
cellgraph/languages.py,sha256=udq9-GXxfbJ5dOClsQ6cFonbekO1s4XNi4e1gEHAeUE,3623
|
|
9
|
+
cellgraph/plan.py,sha256=IOgFxp7qR0d4TRCEk3aNmHD0Xmpj-F67iMk_Cz_E47Q,1243
|
|
10
|
+
cellgraph/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
cellgraph/python.py,sha256=nku01OPyornnp3_VFJQb__5oM4Finz-BjiQby24Ovu0,27128
|
|
12
|
+
cellgraph/vocabulary.py,sha256=sGpgpsBXUWEeMs18yCc62ZWcCzq5bF60pNnxwzQyvAY,9962
|
|
13
|
+
cellgraph-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
+
cellgraph-0.1.0.dist-info/WHEEL,sha256=3NO1oYsF7mANFUWVdyEQLM-zmecczWWEmmF5rEbXrWk,80
|
|
15
|
+
cellgraph-0.1.0.dist-info/METADATA,sha256=ZtoifY4ktBzSncolDNlFQRSI6JDF3H0cMoiC8qGgwuU,2322
|
|
16
|
+
cellgraph-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|