Skip to content

Commit 8b67aa5

Browse files
feat(opensearch): FTRS-856 Index creation and population
1 parent 6f7f4c0 commit 8b67aa5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/workflow/populate_open_search_index.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@
3636
_DESERIALIZER = TypeDeserializer()
3737
EMPTY_SHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
3838
_DEFAULT_DDB_TABLE_BASE = "ftrs-dos-local-database-healthcare-service"
39-
_WS_ENV = (os.environ.get('WORKSPACE') or '').strip()
40-
_WS_NORMALIZED = _WS_ENV.lstrip('-') if _WS_ENV else ''
41-
DEFAULT_DDB_TABLE = _DEFAULT_DDB_TABLE_BASE + (f"-{_WS_NORMALIZED}" if _WS_NORMALIZED else "")
39+
DEFAULT_DDB_TABLE = _DEFAULT_DDB_TABLE_BASE
40+
DDB_IGNORE_WORKSPACE_DEFAULT = True
4241
INDEXING_TIMEOUT_SECONDS = 60
4342
INDEX_PROPERTIES = MAPPINGS_PAYLOAD.get('mappings', {}).get('properties', {})
4443
PRIMARY_KEY_NAME = 'primary_key' if 'primary_key' in INDEX_PROPERTIES else None
@@ -81,6 +80,8 @@ def parse_args(argv: Optional[list[str]] = None) -> argparse.Namespace:
8180
parser.add_argument("--batch-size", dest="batch_size", type=int, default=1, help="Number of records to send in one bulk request (1 = per-document PUT)")
8281
parser.add_argument("--log-level", dest="log_level", default=os.environ.get('LOG_LEVEL', 'INFO'))
8382
parser.add_argument("--schema-config", dest="schema_config", help="Path to JSON schema config that maps DynamoDB attributes to OpenSearch fields")
83+
parser.add_argument("--dynamodb-table-ignore-workspace", dest="ddb_ignore_workspace", default=str(DDB_IGNORE_WORKSPACE_DEFAULT),
84+
help="true|false - when true do NOT append workspace to the DynamoDB table name (default: true)")
8485
return parser.parse_args(argv)
8586

8687
def validate_inputs(open_search_domain: Optional[str], index: Optional[str]) -> None:
@@ -460,9 +461,11 @@ def main(argv: Optional[list[str]] = None) -> int:
460461
ddb_table = args.ddb_table
461462
workspace = args.workspace or os.environ.get('WORKSPACE', '')
462463

463-
final_table = build_name_with_workspace(ddb_table, workspace) if ddb_table else ddb_table
464+
ddb_ignore_workspace = str(args.ddb_ignore_workspace).strip().lower() in ("1", "true", "yes")
465+
466+
final_table = ddb_table if ddb_ignore_workspace or not ddb_table else build_name_with_workspace(ddb_table, workspace)
467+
464468
ws_raw = (workspace or "").strip()
465-
# determine final index, defaulting to triage_code when workspace not set
466469
if not ws_raw:
467470
final_index = args.final_index or os.environ.get('OS_FINAL_INDEX') or "triage_code"
468471
else:

0 commit comments

Comments
 (0)