Skip to content

Commit

Permalink
2025-01-09T14:17:03Z
Browse files Browse the repository at this point in the history
  • Loading branch information
wrmsr committed Jan 9, 2025
1 parent 3ab2d42 commit 2224745
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ominfra/clouds/aws/models/gen/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def gen_operation(

if operation.error_shapes:
fls.append('errors=[')
for osn in [es.name for es in operation.error_shapes]:
for osn in sorted(es.name for es in operation.error_shapes):
fls.append(f' {osn},')
fls.append('],')

Expand Down
3 changes: 2 additions & 1 deletion omlish/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@
)

from .resources import ( # noqa
RelativeResource,
ReadableResource,
get_package_resources,
get_relative_resources,
)

Expand Down
23 changes: 18 additions & 5 deletions omlish/lang/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


@dc.dataclass(frozen=True)
class RelativeResource:
class ReadableResource:
name: str
is_file: bool
read_bytes: ta.Callable[[], bytes]
Expand All @@ -15,13 +15,26 @@ def read_text(self, encoding: str = 'utf-8') -> str:
return self.read_bytes().decode(encoding)


def get_package_resources(anchor: str) -> ta.Mapping[str, ReadableResource]:
lst: list[ReadableResource] = []

for pf in importlib.resources.files(anchor).iterdir():
lst.append(ReadableResource(
name=pf.name,
is_file=pf.is_file(),
read_bytes=pf.read_bytes if pf.is_file() else None, # type: ignore
))

return {r.name: r for r in lst}


def get_relative_resources(
path: str = '',
*,
globals: ta.Mapping[str, ta.Any] | None = None, # noqa
package: str | None = None,
file: str | None = None,
) -> ta.Mapping[str, RelativeResource]:
) -> ta.Mapping[str, ReadableResource]:
if globals is not None:
if not package:
package = globals.get('__package__')
Expand All @@ -45,15 +58,15 @@ def get_relative_resources(

#

lst: list[RelativeResource] = []
lst: list[ReadableResource] = []

if package:
pkg_parts = package.split('.')
if num_up:
pkg_parts = pkg_parts[:-num_up]
anchor = '.'.join([*pkg_parts, *path_parts])
for pf in importlib.resources.files(anchor).iterdir():
lst.append(RelativeResource(
lst.append(ReadableResource(
name=pf.name,
is_file=pf.is_file(),
read_bytes=pf.read_bytes if pf.is_file() else None, # type: ignore
Expand All @@ -73,7 +86,7 @@ def _read_file(fp: str) -> bytes:

for ff in os.listdir(dst_dir):
ff = os.path.join(dst_dir, ff)
lst.append(RelativeResource(
lst.append(ReadableResource(
name=os.path.basename(ff),
is_file=os.path.isfile(ff),
read_bytes=functools.partial(_read_file, ff),
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ segno==1.6.1

duckduckgo_search==7.2.1 # @omlish-venv !13t # segfault lol

boto3>=1.35.94
boto3>=1.35.95
4 changes: 2 additions & 2 deletions requirements-ext.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ customtkinter==5.2.2
##

langchain-anthropic==0.3.1
langchain-chroma==0.1.4
langchain-chroma==0.2.0
langchain-community==0.3.14
langchain-core==0.3.29
langchain-elasticsearch==0.3.0
Expand Down Expand Up @@ -280,7 +280,7 @@ docopt==0.6.2

rapidocr_onnxruntime==1.4.3

gguf==0.13.0
gguf==0.14.0

pytesseract==0.3.13

Expand Down
20 changes: 10 additions & 10 deletions requirements-frz.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ black==24.10.0
bleach==6.2.0
blinker==1.9.0
blis==1.1.0
boto3==1.35.94
botocore==1.35.94
boto3==1.35.95
botocore==1.35.95
Brotli==1.1.0
bs4==0.0.2
bsddb3==6.2.9
Expand Down Expand Up @@ -128,7 +128,7 @@ future==1.0.0
gast==0.6.0
geopandas==1.0.1
gevent==24.11.1
gguf==0.13.0
gguf==0.14.0
gitdb==4.0.12
GitPython==3.1.44
google-api-core==2.24.0
Expand Down Expand Up @@ -211,7 +211,7 @@ kiwisolver==1.4.8
kubernetes==31.0.0
langchain==0.3.14
langchain-anthropic==0.3.1
langchain-chroma==0.1.4
langchain-chroma==0.2.0
langchain-community==0.3.14
langchain-core==0.3.29
langchain-elasticsearch==0.3.0
Expand All @@ -237,13 +237,13 @@ lightning-utilities==0.11.9
litecli==1.13.2
litellm==1.51.0
llama-index-core==0.12.10.post1
llama_cpp_python==0.3.5
llama_cpp_python==0.3.6
llvmlite==0.43.0
Logbook==1.8.0
loralib==0.1.2
lru-dict==1.3.0
lsprotocol==2023.0.1
lupa==2.2
lupa==2.3
lxml==5.3.0
lxml_html_clean==0.4.1
lz4==4.3.3
Expand All @@ -253,7 +253,7 @@ marisa-trie==1.2.1
Markdown==3.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
marshmallow==3.24.1
marshmallow==3.24.2
matplotlib==3.10.0
matplotlib-inline==0.1.7
mccabe==0.7.0
Expand Down Expand Up @@ -361,7 +361,7 @@ pyasn1_modules==0.4.1
pyclipper==1.3.0.post6
pycodestyle==2.12.1
pycparser==2.22
pydantic==2.10.4
pydantic==2.10.5
pydantic-settings==2.7.1
pydantic_core==2.27.2
pyflakes==3.2.0
Expand Down Expand Up @@ -442,7 +442,7 @@ Send2Trash==1.8.3
sentence-transformers==3.3.1
sentencepiece==0.2.0
setproctitle==1.3.4
setuptools==75.7.0
setuptools==75.8.0
setuptools-scm==8.1.0
shapely==2.0.6
shellingham==1.5.4
Expand All @@ -465,7 +465,7 @@ spacy-loggers==1.0.5
SPARQLWrapper==1.8.5
SQLAlchemy==2.0.36
sqlean.py==3.47.0
sqlglot==26.1.2
sqlglot==26.1.3
sqlite-vec==0.1.6
sqlparse==0.4.4
srsly==2.5.0
Expand Down

0 comments on commit 2224745

Please sign in to comment.