Example #1
0
def add_output_attributes(candset, l_output_attrs=None, r_output_attrs=None, l_output_prefix='ltable_',
                          r_output_prefix='rtable_', validate=True, copy_props=True,
                          delete_from_catalog=True, verbose=False):

    if not isinstance(candset, pd.DataFrame):
        logger.error('Input object is not of type pandas data frame')
        raise AssertionError('Input object is not of type pandas data frame')

    # # get metadata
    key, fk_ltable, fk_rtable, ltable, rtable, l_key, r_key = cm.get_metadata_for_candset(candset, logger, verbose)
    if validate:
        cm.validate_metadata_for_candset(candset, key, fk_ltable, fk_rtable, ltable, rtable, l_key, r_key,
                                         logger, verbose)
    index_values = candset.index

    df = _add_output_attributes(candset, fk_ltable, fk_rtable, ltable, rtable, l_key, r_key,
                                l_output_attrs, r_output_attrs, l_output_prefix, r_output_prefix,
                                validate=False)

    df.set_index(index_values, inplace=True)
    if copy_props:
        cm.init_properties(df)
        cm.copy_properties(candset, df)
        if delete_from_catalog:
            cm.del_all_properties(candset)
    return df
Example #2
0
def add_output_attributes(candset,
                          l_output_attrs=None,
                          r_output_attrs=None,
                          l_output_prefix='ltable_',
                          r_output_prefix='rtable_',
                          validate=True,
                          copy_props=True,
                          delete_from_catalog=True,
                          verbose=False):

    if not isinstance(candset, pd.DataFrame):
        logger.error('Input object is not of type pandas data frame')
        raise AssertionError('Input object is not of type pandas data frame')

    # # get metadata
    key, fk_ltable, fk_rtable, ltable, rtable, l_key, r_key = cm.get_metadata_for_candset(
        candset, logger, verbose)
    if validate:
        cm.validate_metadata_for_candset(candset, key, fk_ltable, fk_rtable,
                                         ltable, rtable, l_key, r_key, logger,
                                         verbose)
    index_values = candset.index

    df = _add_output_attributes(candset,
                                fk_ltable,
                                fk_rtable,
                                ltable,
                                rtable,
                                l_key,
                                r_key,
                                l_output_attrs,
                                r_output_attrs,
                                l_output_prefix,
                                r_output_prefix,
                                validate=False)

    df.set_index(index_values, inplace=True)
    if copy_props:
        cm.init_properties(df)
        cm.copy_properties(candset, df)
        if delete_from_catalog:
            cm.del_all_properties(candset)
    return df
Example #3
0
 def test_del_all_properties_df_notin_catalog(self):
     A = pd.read_csv(path_a)
     cm.del_all_properties(A)
Example #4
0
 def test_del_all_properties_invalid_df(self):
     cm.del_all_properties(None)
Example #5
0
 def test_del_all_properties_valid_2(self):
     A = read_csv_metadata(path_a)
     B = read_csv_metadata(path_b)
     C = read_csv_metadata(path_c, ltable=A, rtable=B)
     cm.del_all_properties(C)
     self.assertEqual(cm.is_dfinfo_present(C), False)
Example #6
0
 def test_del_all_properties_valid_1(self):
     A = read_csv_metadata(path_a)
     cm.del_all_properties(A)
     self.assertEqual(cm.is_dfinfo_present(A), False)