def test_decompose_lineage():
    test_product_id = 'product_id'
    test_uri = 'ad:STARS/galaxies.fits.gz'
    test_lineage = f'{test_product_id}/{test_uri}'
    actual_product_id, actual_uri = mc.decompose_lineage(test_lineage)
    assert actual_product_id == test_product_id, f'expected {test_product_id}'
    assert actual_uri == test_uri, f'expected {test_uri}'

    with pytest.raises(mc.CadcException):
        mc.decompose_lineage('')
def test_decompose_lineage():
    test_product_id = 'product_id'
    test_uri = 'ad:STARS/galaxies.fits.gz'
    test_lineage = '{}/{}'.format(test_product_id, test_uri)
    actual_product_id, actual_uri = mc.decompose_lineage(test_lineage)
    assert actual_product_id == test_product_id, 'expected {}'.format(
        test_product_id)
    assert actual_uri == test_uri, 'expected {}'.format(test_uri)

    with pytest.raises(mc.CadcException):
        mc.decompose_lineage('')
Esempio n. 3
0
def _get_uris(args):
    result = []
    if args.lineage:
        for ii in args.lineage:
            ignore_product_id, uri = mc.decompose_lineage(ii)
            result.append(uri)
    elif args.local:
        for ii in args.local:
            file_id = mc.StorageName.remove_extensions(os.path.basename(ii))
            file_name = f'{file_id}.fits'
            result.append(PHANGSName(file_name=file_name).file_uri)
    else:
        raise mc.CadcException(f'Could not define uri from these args {args}')
    return result
Esempio n. 4
0
def _get_uris(args):
    result = []
    if args.lineage:
        for ii in args.lineage:
            ignore, uri = mc.decompose_lineage(ii)
            result.append(uri)
    elif args.local:
        for ii in args.local:
            obs_id = mc.StorageName.remove_extensions(os.path.basename(ii))
            uri = dn.DAOName(obs_id=obs_id).file_uri
            result.append(uri)
    elif args.observation:
        uri = dn.DAOName(obs_id=args.observation[1]).file_uri
        result.append(uri)
    else:
        raise mc.CadcException(f'Could not define uri from these args {args}')
    return result
Esempio n. 5
0
def _get_uri(args):
    result = None
    if args.local:
        if args.local[0].endswith('.jpg'):
            pass
        else:
            result = args.local[0]
    elif args.lineage:
        temp_product_id, temp_uri = mc.decompose_lineage(args.lineage[0])
        if temp_uri.endswith('.jpg'):
            pass
        else:
            result = temp_uri
    else:
        raise mc.CadcException(
            'Could not define uri from these args {}'.format(args))
    return result
Esempio n. 6
0
    def build_blueprints(args):
        """This application relies on the caom2utils fits2caom2 ObsBlueprint
        definition for mapping FITS file values to CAOM model element
        attributes. This method builds the VLASS blueprint for a single
        artifact.

        The blueprint handles the mapping of values with cardinality of 1:1
        between the blueprint entries and the model attributes.

        :param args """
        module = importlib.import_module(__name__)
        blueprints = {}
        for ii in args.lineage:
            blueprint = ObsBlueprint(module=module)
            accumulate_wcs(blueprint)
            product_id, artifact_uri = mc.decompose_lineage(ii)
            blueprints[artifact_uri] = blueprint
        return blueprints