Spaces:
Running
Running
Move away from deprecated pkg_resources
Browse files- sage/config.py +4 -4
sage/config.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
"""Utility methods to define and validate flags."""
|
| 2 |
|
| 3 |
import argparse
|
|
|
|
| 4 |
import logging
|
| 5 |
import os
|
| 6 |
import re
|
| 7 |
from typing import Callable
|
| 8 |
|
| 9 |
-
import pkg_resources
|
| 10 |
from configargparse import ArgumentParser
|
| 11 |
|
| 12 |
from sage.reranker import RerankerProvider
|
|
@@ -67,8 +67,8 @@ def add_config_args(parser: ArgumentParser):
|
|
| 67 |
help="Path to .yaml configuration file.",
|
| 68 |
)
|
| 69 |
args, _ = parser.parse_known_args()
|
| 70 |
-
config_file =
|
| 71 |
-
parser.set_defaults(config=config_file)
|
| 72 |
return lambda _: True
|
| 73 |
|
| 74 |
|
|
@@ -411,7 +411,7 @@ def validate_indexing_args(args):
|
|
| 411 |
if args.include and args.exclude:
|
| 412 |
raise ValueError("At most one of indexing.include and indexing.exclude can be specified.")
|
| 413 |
if not args.include and not args.exclude:
|
| 414 |
-
args.exclude =
|
| 415 |
if args.include and not os.path.exists(args.include):
|
| 416 |
raise ValueError(f"Path --include={args.include} does not exist.")
|
| 417 |
if args.exclude and not os.path.exists(args.exclude):
|
|
|
|
| 1 |
"""Utility methods to define and validate flags."""
|
| 2 |
|
| 3 |
import argparse
|
| 4 |
+
import importlib.resources as resources
|
| 5 |
import logging
|
| 6 |
import os
|
| 7 |
import re
|
| 8 |
from typing import Callable
|
| 9 |
|
|
|
|
| 10 |
from configargparse import ArgumentParser
|
| 11 |
|
| 12 |
from sage.reranker import RerankerProvider
|
|
|
|
| 67 |
help="Path to .yaml configuration file.",
|
| 68 |
)
|
| 69 |
args, _ = parser.parse_known_args()
|
| 70 |
+
config_file = resources.files("sage").joinpath(f"configs/{args.mode}.yaml")
|
| 71 |
+
parser.set_defaults(config=str(config_file))
|
| 72 |
return lambda _: True
|
| 73 |
|
| 74 |
|
|
|
|
| 411 |
if args.include and args.exclude:
|
| 412 |
raise ValueError("At most one of indexing.include and indexing.exclude can be specified.")
|
| 413 |
if not args.include and not args.exclude:
|
| 414 |
+
args.exclude = str(resources.files("sage").joinpath("sample-exclude.txt"))
|
| 415 |
if args.include and not os.path.exists(args.include):
|
| 416 |
raise ValueError(f"Path --include={args.include} does not exist.")
|
| 417 |
if args.exclude and not os.path.exists(args.exclude):
|