Skip to content

Commit 96cfe29

Browse files
committed
Revert "reverted retries on the command line - due to issues with passing to solids in the ingest pipeline. Hard coded at 12 for now."
This reverts commit 78c2dab.
1 parent 78c2dab commit 96cfe29

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

hca/staging_area_validator.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ def main(self):
4242

4343
date_format = "%Y-%m-%dT%H:%M:%S.%fZ"
4444

45-
# removing total_retries as a config for now
4645
def __init__(
4746
self,
4847
staging_area: str,
4948
ignore_dangling_inputs: bool,
5049
validate_json: bool,
51-
# total_retries,
50+
total_retries,
5251
) -> None:
5352
super().__init__()
5453
self.staging_area = staging_area
@@ -58,7 +57,7 @@ def __init__(
5857
self.gcs = gcs.Client()
5958

6059
# Number of retries for validation
61-
# self.total_retries = total_retries
60+
self.total_retries = total_retries
6261
# A boolean to tell us if this is a delta or non-delta staging area
6362
self.is_delta = None
6463
# A mapping of data file name to metadata id
@@ -299,8 +298,7 @@ def validate_file_json(
299298
if self.validate_json:
300299
print(f"Validating JSON of {file_name}")
301300
try:
302-
# self.validator.validate_json(file_json, self.total_retries, schema)
303-
self.validator.validate_json(file_json, schema)
301+
self.validator.validate_json(file_json, self.total_retries, schema)
304302
except Exception as e:
305303
log.error("File %s failed json validation.", file_name)
306304
self.file_errors[file_name] = e
@@ -371,31 +369,27 @@ class SchemaValidator:
371369
def validate_json(
372370
cls,
373371
file_json: JSON,
374-
# total_retries: int,
372+
total_retries: int,
375373
schema: Optional[JSON] = None,
376374
) -> None:
377375
if schema is None:
378376
try:
379-
# schema = cls._download_schema(file_json["describedBy"], total_retries)
380-
schema = cls._download_schema(file_json["describedBy"])
377+
schema = cls._download_schema(file_json["describedBy"], total_retries)
381378
except json.decoder.JSONDecodeError as e:
382379
schema_url = file_json["describedBy"]
383380
raise Exception("Failed to parse schema JSON", schema_url) from e
384381
validate(file_json, schema, format_checker=FormatChecker())
385382

386383
@classmethod
387384
# setting to maxsize=None so as not to evict old values, and maybe help avoid connectivity issues (DI-22)
388-
# Could also have used the dagster.RetryPolicy for this
389385
@lru_cache(maxsize=None)
390-
# def _download_schema(cls, schema_url: str, total_retries: int) -> JSON:
391-
def _download_schema(cls, schema_url: str) -> JSON:
386+
def _download_schema(cls, schema_url: str, total_retries: int) -> JSON:
392387
log.debug("Downloading schema %s", schema_url)
393388

394389
s = requests.Session()
395-
# log.debug(f"total_retries = {total_retries}")
390+
log.debug(f"total_retries = {total_retries}")
396391
retries = Retry(
397-
# total=total_retries,
398-
total=12,
392+
total=total_retries,
399393
backoff_factor=0.2,
400394
status_forcelist=[500, 502, 503, 504],
401395
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "hca-import-validation"
8-
version = "0.0.12"
8+
version = "0.0.11"
99
description = "HCA Staging Import Validation"
1010
urls = {"Source" = "https://github.com/dataBiosphere/hca-import-validation"}
1111
classifiers = [

validate_staging_area.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ def _parse_args(argv):
3333
dest="validate_json",
3434
help="Do not validate JSON documents against their schema.",
3535
)
36-
# May add this back later if we really need to set this in the config
37-
# parser.add_argument(
38-
# "--total-retries",
39-
# "-t",
40-
# type=int,
41-
# default=10,
42-
# dest="total_retries",
43-
# help="The number of times to retry the validation process.",
44-
# )
36+
parser.add_argument(
37+
"--total-retries",
38+
"-t",
39+
type=int,
40+
default=10,
41+
dest="total_retries",
42+
help="The number of times to retry the validation process.",
43+
)
4544
return parser.parse_args(argv)
4645

4746

@@ -51,6 +50,6 @@ def _parse_args(argv):
5150
staging_area=args.staging_area,
5251
ignore_dangling_inputs=args.ignore_dangling_inputs,
5352
validate_json=args.validate_json,
54-
# total_retries=args.total_retries,
53+
total_retries=args.total_retries,
5554
)
5655
sys.exit(adapter.main())

0 commit comments

Comments
 (0)