Skip to content

Commit 8bde049

Browse files
authored
Fix jinja sandbox (#491)
* Use sandboxed jinja environment * Fix import * Increment version * Update python requirement * Update test python versions
1 parent 117f689 commit 8bde049

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
python_version: ["3.12"]
2626
include:
2727
- os: windows-latest
28-
python_version: "3.7"
28+
python_version: "3.9"
2929
- os: macos-latest
30-
python_version: "3.8"
30+
python_version: "3.9"
3131
- os: ubuntu-latest
3232
python_version: "3.9"
3333
- os: windows-latest

setup.cfg

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[metadata]
2-
version = 0.7.2
2+
version = 0.7.3
33
description = Integrating LLMs into structured NLP pipelines
44
author = Explosion
55
author_email = [email protected]
@@ -16,8 +16,6 @@ classifiers =
1616
Operating System :: MacOS :: MacOS X
1717
Operating System :: Microsoft :: Windows
1818
Programming Language :: Python :: 3
19-
Programming Language :: Python :: 3.7
20-
Programming Language :: Python :: 3.8
2119
Programming Language :: Python :: 3.9
2220
Programming Language :: Python :: 3.10
2321
Programming Language :: Python :: 3.11
@@ -30,7 +28,7 @@ project_urls =
3028
[options]
3129
zip_safe = false
3230
include_package_data = true
33-
python_requires = >=3.7
31+
python_requires = >=3.9
3432
install_requires =
3533
spacy>=3.5,<4.0
3634
jinja2

spacy_llm/tasks/builtin_task.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, cast
55

66
import jinja2
7+
import jinja2.sandbox
78
import srsly
89
from spacy import Errors, Language, util
910
from spacy.tokens import Doc
@@ -64,7 +65,7 @@ def generate_prompts(
6465
prompts in case of multiple shards) and the corresponding shards. The relationship between shard and prompt
6566
is 1:1.
6667
"""
67-
environment = jinja2.Environment()
68+
environment = jinja2.sandbox.SandboxedEnvironment()
6869
_template = environment.from_string(self._template)
6970

7071
def render_template(shard: Doc, i_shard: int, i_doc: int, n_shards: int) -> str:

0 commit comments

Comments
 (0)