forked from y-scope/clp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clp-package: Prevent query scheduler from scheduling two IR extractio…
…n jobs targeting the same file split. (y-scope#483)
- Loading branch information
Showing
6 changed files
with
181 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
components/clp-py-utils/clp_py_utils/create-results-cache-indices.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import argparse | ||
import logging | ||
import sys | ||
|
||
from pymongo import IndexModel, MongoClient | ||
|
||
# Setup logging | ||
# Create logger | ||
logger = logging.getLogger(__file__) | ||
logger.setLevel(logging.INFO) | ||
# Setup console logging | ||
logging_console_handler = logging.StreamHandler() | ||
logging_formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") | ||
logging_console_handler.setFormatter(logging_formatter) | ||
logger.addHandler(logging_console_handler) | ||
|
||
|
||
def main(argv): | ||
args_parser = argparse.ArgumentParser(description="Creates results cache indices for CLP.") | ||
args_parser.add_argument("--uri", required=True, help="URI of the results cache.") | ||
args_parser.add_argument("--ir-collection", required=True, help="Collection for IR metadata.") | ||
parsed_args = args_parser.parse_args(argv[1:]) | ||
|
||
results_cache_uri = parsed_args.uri | ||
ir_collection_name = parsed_args.ir_collection | ||
|
||
try: | ||
with MongoClient(results_cache_uri) as results_cache_client: | ||
ir_collection = results_cache_client.get_default_database()[ir_collection_name] | ||
|
||
file_split_id_index = IndexModel(["file_split_id"]) | ||
orig_file_id_index = IndexModel(["orig_file_id", "begin_msg_ix", "end_msg_ix"]) | ||
ir_collection.create_indexes([file_split_id_index, orig_file_id_index]) | ||
except Exception: | ||
logger.exception("Failed to create clp results cache indices.") | ||
return -1 | ||
|
||
return 0 | ||
|
||
|
||
if "__main__" == __name__: | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters