Skip to content

Commit 8182868

Browse files
committed
Flatten python package
1 parent 7a63185 commit 8182868

File tree

14 files changed

+22
-21
lines changed

14 files changed

+22
-21
lines changed

benchmarks/bench_json_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from outlines_core.fsm import Index, Vocabulary
2-
from outlines_core.fsm.json_schema import build_regex_from_schema
1+
from outlines_core import Index, Vocabulary
2+
from outlines_core.json_schema import build_regex_from_schema
33

44
simple_schema = """{
55
"$defs": {

benchmarks/bench_regex_guide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from concurrent.futures import ThreadPoolExecutor
33

44
import psutil
5-
from outlines_core.fsm import Guide, Index, Vocabulary
5+
from outlines_core import Guide, Index, Vocabulary
66

77
regex_samples = {
88
"email": r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",

python/outlines_core/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
"""Outlines is a Generative Model Programming Framework."""
1+
"""This package provides core functionality for structured generation, formerly implemented in Outlines."""
22
from importlib.metadata import PackageNotFoundError, version
33

4+
from .outlines_core_rs import Guide, Index, Vocabulary
5+
46
try:
57
__version__ = version("outlines_core")
68
except PackageNotFoundError:

python/outlines_core/fsm/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ select = C,E,F,W
44
ignore = E203,E231,E501,E741,W503,W504,C901,E731
55
per-file-ignores =
66
**/__init__.py:F401,F403
7-
tests/fsm/test_json_schema.py: E201
7+
tests/test_json_schema.py: E201
88
exclude =
99
outlines_core/_version.py

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
rust_extensions = [
1010
RustExtension(
11-
"outlines_core.fsm.outlines_core_rs",
11+
"outlines_core.outlines_core_rs",
1212
f"{CURRENT_DIR}/Cargo.toml",
1313
binding=Binding.PyO3,
1414
features=["python-bindings"],

src/python_bindings/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ macro_rules! type_name {
2121
};
2222
}
2323

24-
#[pyclass(name = "Guide", module = "outlines_core.fsm.outlines_core_rs")]
24+
#[pyclass(name = "Guide", module = "outlines_core.outlines_core_rs")]
2525
#[derive(Clone, Debug, PartialEq, Encode, Decode)]
2626
pub struct PyGuide {
2727
state: StateId,
@@ -90,8 +90,8 @@ impl PyGuide {
9090

9191
fn __reduce__(&self) -> PyResult<(PyObject, (Vec<u8>,))> {
9292
Python::with_gil(|py| {
93-
let cls = PyModule::import_bound(py, "outlines_core.fsm.outlines_core_rs")?
94-
.getattr("Guide")?;
93+
let cls =
94+
PyModule::import_bound(py, "outlines_core.outlines_core_rs")?.getattr("Guide")?;
9595
let binary_data: Vec<u8> =
9696
bincode::encode_to_vec(self, config::standard()).map_err(|e| {
9797
PyErr::new::<PyValueError, _>(format!("Serialization of Guide failed: {}", e))
@@ -110,7 +110,7 @@ impl PyGuide {
110110
}
111111
}
112112

113-
#[pyclass(name = "Index", module = "outlines_core.fsm.outlines_core_rs")]
113+
#[pyclass(name = "Index", module = "outlines_core.outlines_core_rs")]
114114
#[derive(Clone, Debug, PartialEq, Encode, Decode)]
115115
pub struct PyIndex(Arc<Index>);
116116

@@ -166,8 +166,8 @@ impl PyIndex {
166166

167167
fn __reduce__(&self) -> PyResult<(PyObject, (Vec<u8>,))> {
168168
Python::with_gil(|py| {
169-
let cls = PyModule::import_bound(py, "outlines_core.fsm.outlines_core_rs")?
170-
.getattr("Index")?;
169+
let cls =
170+
PyModule::import_bound(py, "outlines_core.outlines_core_rs")?.getattr("Index")?;
171171
let binary_data: Vec<u8> = bincode::encode_to_vec(&self.0, config::standard())
172172
.map_err(|e| {
173173
PyErr::new::<PyValueError, _>(format!("Serialization of Index failed: {}", e))
@@ -186,7 +186,7 @@ impl PyIndex {
186186
}
187187
}
188188

189-
#[pyclass(name = "Vocabulary", module = "outlines_core.fsm.outlines_core_rs")]
189+
#[pyclass(name = "Vocabulary", module = "outlines_core.outlines_core_rs")]
190190
#[derive(Clone, Debug, Encode, Decode)]
191191
pub struct PyVocabulary(Vocabulary);
192192

@@ -299,7 +299,7 @@ impl PyVocabulary {
299299

300300
fn __reduce__(&self) -> PyResult<(PyObject, (Vec<u8>,))> {
301301
Python::with_gil(|py| {
302-
let cls = PyModule::import_bound(py, "outlines_core.fsm.outlines_core_rs")?
302+
let cls = PyModule::import_bound(py, "outlines_core.outlines_core_rs")?
303303
.getattr("Vocabulary")?;
304304
let binary_data: Vec<u8> =
305305
bincode::encode_to_vec(self, config::standard()).map_err(|e| {

tests/fsm/test_guide.py renamed to tests/test_guide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Dict, List, Union
44

55
import pytest
6-
from outlines_core.fsm import Guide, Index, Vocabulary
6+
from outlines_core import Guide, Index, Vocabulary
77

88

99
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)