Skip to content

Commit 5fd05d3

Browse files
committed
Update Lliam repository to allow injectable FS
1 parent 3d4d68b commit 5fd05d3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

aws_doc_sdk_examples_tools/lliam/adapters/repository.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any, Generator, Iterable, List, Tuple
55

66
from aws_doc_sdk_examples_tools.doc_gen import DocGen, Example
7-
from aws_doc_sdk_examples_tools.fs import PathFs
7+
from aws_doc_sdk_examples_tools.fs import Fs, PathFs
88
from aws_doc_sdk_examples_tools.lliam.domain.model import Prompt
99
from aws_doc_sdk_examples_tools.lliam.shared_constants import BATCH_PREFIX
1010

@@ -76,9 +76,9 @@ def _get(self, id: str) -> Prompt:
7676

7777

7878
class FsPromptRepository(AbstractPromptRepository):
79-
def __init__(self):
79+
def __init__(self, fs: Fs = PathFs()):
8080
super().__init__()
81-
self.fs = PathFs()
81+
self.fs = fs
8282

8383
def rollback(self):
8484
# TODO: This is not what rollback is for. We should be rolling back any
@@ -120,13 +120,19 @@ def _get_new_prompts(self, doc_gen_root: str) -> List[Prompt]:
120120

121121

122122
class FsDocGenRepository(AbstractDocGenRepository):
123+
def __init__(self, fs: Fs = PathFs()):
124+
super().__init__()
125+
self.fs = fs
126+
123127
def rollback(self):
124128
# TODO: This is not what rollback is for. We should be rolling back any
125129
# file changes
126130
self._doc_gen = None
127131

128132
def _get_new_prompts(self, doc_gen_root: str) -> List[Prompt]:
129-
self._doc_gen = DocGen.from_root(Path(doc_gen_root))
133+
# Right now this is the only instance of DocGen used in this Repository,
134+
# but if that changes we need to move it up.
135+
self._doc_gen = DocGen.from_root(Path(doc_gen_root), fs=self.fs)
130136
self._doc_gen.collect_snippets()
131137
new_examples = self._get_new_examples()
132138
prompts = self._examples_to_prompts(new_examples)

0 commit comments

Comments
 (0)