@@ -53,7 +53,9 @@ def __init__(
5353 f"Initializing DataModelGraphExplorer object from { inputMModelLocation } schema."
5454 )
5555
56+ # self.inputMModelLocation remains for backwards compatibility
5657 self .inputMModelLocation = inputMModelLocation
58+ self .path_to_json_ld = inputMModelLocation
5759
5860 data_model_parser = DataModelParser (path_to_data_model = self .inputMModelLocation )
5961 # Parse Model
@@ -315,62 +317,77 @@ def populateModelManifest(
315317 manifestPath , emptyManifestURL , return_excel = return_excel , title = title
316318 )
317319
318- def submit_metadata_manifest (
320+ def submit_metadata_manifest ( # pylint: disable=too-many-arguments, too-many-locals
319321 self ,
320322 manifest_path : str ,
321- path_to_json_ld : str ,
322323 dataset_id : str ,
323324 manifest_record_type : str ,
324325 restrict_rules : bool ,
325326 access_token : Optional [str ] = None ,
326327 validate_component : Optional [str ] = None ,
327328 file_annotations_upload : bool = True ,
328329 hide_blanks : bool = False ,
329- project_scope : List = None ,
330+ project_scope : Optional [ list ] = None ,
330331 table_manipulation : str = "replace" ,
331332 table_column_names : str = "class_label" ,
332333 annotation_keys : str = "class_label" ,
333334 ) -> str :
334- """Wrap methods that are responsible for validation of manifests for a given component, and association of the
335- same manifest file with a specified dataset.
335+ """
336+ Wrap methods that are responsible for validation of manifests for a given component,
337+ and association of the same manifest file with a specified dataset.
338+
336339 Args:
337- manifest_path: Path to the manifest file, which contains the metadata.
338- dataset_id: Synapse ID of the dataset on Synapse containing the metadata manifest file.
339- validate_component: Component from the schema.org schema based on which the manifest template has been generated.
340- file_annotations_upload (bool): Default to True. If false, do not add annotations to files.
341- Returns:
342- Manifest ID: If both validation and association were successful.
343- Exceptions:
340+ manifest_path (str): Path to the manifest file, which contains the metadata.
341+ dataset_id (str): Synapse ID of the dataset on Synapse containing the
342+ metadata manifest file.
343+ manifest_record_type (str): How the manifest is stored in Synapse
344+ restrict_rules (bool):
345+ If True: bypass great expectations and restrict rule options to
346+ those implemented in house
347+ access_token (Optional[str], optional): Defaults to None.
348+ validate_component (Optional[str], optional): Component from the schema.org
349+ schema based on which the manifest template has been generated.
350+ file_annotations_upload (bool, optional): Default to True. If false, do
351+ not add annotations to files. Defaults to True.
352+ hide_blanks (bool, optional): Defaults to False.
353+ project_scope (Optional[list], optional): Defaults to None.
354+ table_manipulation (str, optional): Defaults to "replace".
355+ table_column_names (str, optional): Defaults to "class_label".
356+ annotation_keys (str, optional): Defaults to "class_label".
357+
358+ Raises:
344359 ValueError: When validate_component is provided, but it cannot be found in the schema.
345360 ValidationError: If validation against data model was not successful.
346- """
347361
362+ Returns:
363+ str: If both validation and association were successful.
364+ """
348365 # TODO: avoid explicitly exposing Synapse store functionality
349366 # just instantiate a Store class and let it decide at runtime/config
350367 # the store type
351368 syn_store = SynapseStorage (
352369 access_token = access_token , project_scope = project_scope
353370 )
354371 manifest_id = None
355- censored_manifest_id = None
356372 restrict_maniest = False
357373 censored_manifest_path = manifest_path .replace (".csv" , "_censored.csv" )
358374 # check if user wants to perform validation or not
359375 if validate_component is not None :
360376 try :
361- # check if the component ("class" in schema) passed as argument is valid (present in schema) or not
377+ # check if the component ("class" in schema) passed as argument is valid
378+ # (present in schema) or not
362379 self .dmge .is_class_in_schema (validate_component )
363- except :
364- # a KeyError exception is raised when validate_component fails in the try-block above
365- # here, we are suppressing the KeyError exception and replacing it with a more
366- # descriptive ValueError exception
380+ except Exception as exc :
381+ # a KeyError exception is raised when validate_component fails in the
382+ # try-block above here, we are suppressing the KeyError exception and
383+ # replacing it with a more descriptive ValueError exception
367384 raise ValueError (
368385 f"The component '{ validate_component } ' could not be found "
369- f"in the schema here '{ path_to_json_ld } '"
370- )
386+ f"in the schema here '{ self . path_to_json_ld } '"
387+ ) from exc
371388
372389 # automatic JSON schema generation and validation with that JSON schema
373- val_errors , val_warnings = self .validateModelManifest (
390+ val_errors , _ = self .validateModelManifest (
374391 manifestPath = manifest_path ,
375392 rootNode = validate_component ,
376393 restrict_rules = restrict_rules ,
@@ -382,7 +399,7 @@ def submit_metadata_manifest(
382399 if val_errors == []:
383400 # upload manifest file from `manifest_path` path to entity with Syn ID `dataset_id`
384401 if os .path .exists (censored_manifest_path ):
385- censored_manifest_id = syn_store .associateMetadataWithFiles (
402+ syn_store .associateMetadataWithFiles (
386403 dmge = self .dmge ,
387404 metadataManifestPath = censored_manifest_path ,
388405 datasetId = dataset_id ,
@@ -408,7 +425,7 @@ def submit_metadata_manifest(
408425 file_annotations_upload = file_annotations_upload ,
409426 )
410427
411- logger .info (f "No validation errors occured during validation." )
428+ logger .info ("No validation errors occured during validation." )
412429 return manifest_id
413430
414431 else :
@@ -419,7 +436,7 @@ def submit_metadata_manifest(
419436
420437 # no need to perform validation, just submit/associate the metadata manifest file
421438 if os .path .exists (censored_manifest_path ):
422- censored_manifest_id = syn_store .associateMetadataWithFiles (
439+ syn_store .associateMetadataWithFiles (
423440 dmge = self .dmge ,
424441 metadataManifestPath = censored_manifest_path ,
425442 datasetId = dataset_id ,
0 commit comments