Skip to content

Commit

Permalink
Move away from deprecated pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
iuliaturc committed Oct 22, 2024
1 parent fb6fe4f commit e3045af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sage/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Utility methods to define and validate flags."""

import argparse
import importlib.resources as resources
import logging
import os
import re
from typing import Callable

import pkg_resources
from configargparse import ArgumentParser

from sage.reranker import RerankerProvider
Expand Down Expand Up @@ -67,8 +67,8 @@ def add_config_args(parser: ArgumentParser):
help="Path to .yaml configuration file.",
)
args, _ = parser.parse_known_args()
config_file = pkg_resources.resource_filename(__name__, f"configs/{args.mode}.yaml")
parser.set_defaults(config=config_file)
config_file = resources.files("sage").joinpath(f"configs/{args.mode}.yaml")
parser.set_defaults(config=str(config_file))
return lambda _: True


Expand Down Expand Up @@ -411,7 +411,7 @@ def validate_indexing_args(args):
if args.include and args.exclude:
raise ValueError("At most one of indexing.include and indexing.exclude can be specified.")
if not args.include and not args.exclude:
args.exclude = pkg_resources.resource_filename(__name__, "sample-exclude.txt")
args.exclude = str(resources.files("sage").joinpath("sample-exclude.txt"))
if args.include and not os.path.exists(args.include):
raise ValueError(f"Path --include={args.include} does not exist.")
if args.exclude and not os.path.exists(args.exclude):
Expand Down

0 comments on commit e3045af

Please sign in to comment.