empd_admin.accept module

Module for accepting erroneous meta data

Errornous fields, i.e. meta data cells that do not pass the EMPD-data, tests, can be accepted by modifying the okexcept column in the meta data sheet.

The functions here are also available as unaccept and accept commnds of the empd-admin shell command.

Functions

accept(meta, what[, commit, skip_ci, …])

Accept failed metadata

accept_query(meta, query, columns[, commit, …])

Accept failed metadata based on a query for the pandas.DataFrame.query

unaccept(meta, what[, commit, skip_ci, …])

Reverse acceptance for failed meta data

unaccept_query(meta, query, columns[, …])

Reverse acceptance for failed meta data based on a SQL query

empd_admin.accept.accept(meta, what, commit=True, skip_ci=False, raise_error=False, exact=False, local_repo=None)

Accept failed metadata

This function marks columns for specific cells as okexcept, such that it passes the EMPD-data tests

Parameters
  • meta (str) – The path to the metadata

  • what (list of str) – A list of strings like sample:column where sample is a regular expression (or the name of the sample if exact) and the column is the column for the corresponding sample that shall be accepted. The sample can also be 'all' to match all samples in the metadata

  • commit (bool) – If True, commit the changes in the repository of meta

  • skip_ci (bool) – If True and commit, then [skip ci] will be added to the commit message

  • raise_error (bool) – If True, raise an error on Failure, otherwise return the error msg

  • except (bool) – If True, samples must be euqal to the sample part in what. Otherwise we use regular expressions

  • local_repo (str) – The path of the local EMPD-data repository. If None, it will be assumed to be the directory of the given meta.

  • Returs

  • ------

  • str – The status message. None if everything is allright.

Examples

Accept wrong countries for all samples:

accept(meta, ['all:Country'])

Accept wrong latitudes and longitudes for all samples that start with 'Barboni':

accept(meta, ['Barboni:Latitude', 'Barboni:Longitude'])

Accept wrong Temperature for the sample 'Beaudouin_a1' and nothing else:

accept(meta, ['Beaudouin_a1:Temperature'], exact=True)

Note

If you skip the exact parameter above, wrong temperatures would also be accepted for the sample Beaudouin_a10!

empd_admin.accept.accept_query(meta, query, columns, commit=True, skip_ci=False, raise_error=False, local_repo=None)

Accept failed metadata based on a query for the pandas.DataFrame.query

This function can accept failed columns for samples based on a query.

The sql expression would be something like:

UPDATE meta SET okexcept = ','.join(columns) WHERE query
Parameters
  • meta (str) – The path to the metadata that shall be queried

  • query (str) – The WHERE part of the query (see empd_admin.query.query_samples()).

  • columns (list of str) – The columns that shall be marked as accepted (they will be appended to the existing columns)

  • commit (bool) – If True, commit the changes in the repository local_repo

  • skip_ci (bool) – If True and commit, then [skip ci] will be added to the commit message

  • raise_error (bool) – If True, raise an error on Failure, otherwise return the error msg

  • local_repo (str) – The path of the local EMPD-data repository. If None, it will be assumed to be the directory of the given meta.

Returns

The status message. None if everything is allright.

Return type

str

See also

accept()

Examples

Accept missing Latitudes and Longitudes:

accept_query(
    meta, "Latitude is NULL or Longitude is NULL", ['Country'])
empd_admin.accept.unaccept(meta, what, commit=True, skip_ci=False, raise_error=False, exact=False, local_repo=None)

Reverse acceptance for failed meta data

This function reverses the acceptance made by the accept() or accept_query() function. Arguments are the same as for the accept function, despite the fact that the column part in what can also be all.

Parameters
  • meta (str) – The path to the metadata

  • what (list of str) – A list of strings like sample:column where sample is a regular expression (or the name of the sample if exact) and the column is the column for the corresponding sample that shall be accepted

  • commit (bool) – If True, commit the changes in the repository of meta

  • skip_ci (bool) – If True and commit, then [skip ci] will be added to the commit message

  • raise_error (bool) – If True, raise an error on Failure, otherwise return the error msg

  • except (bool) – If True, samples must be euqal to the sample part in what. Otherwise we use regular expressions

  • local_repo (str) – The path of the local EMPD-data repository. If None, it will be assumed to be the directory of the given meta.

  • Returs

  • ------

  • str – The status message. None if everything is allright.

Examples

Do not accept any failure for any column:

unaccept(meta, ['all:all'])

Do not accept any failure for latitudes or longitudes with samples that start with 'Barboni':

unaccept(meta, ['Barboni:Latitude', 'Barboni:Longitude'])

Do not accept wrong Temperature for the sample 'Beaudouin_a1':

unaccept(meta, ['Beaudouin_a1:Temperature'], exact=True)

Note

If you skip the exact parameter above, wrong temperatures would also be not accepted anymore for the sample Beaudouin_a10!

empd_admin.accept.unaccept_query(meta, query, columns, commit=True, skip_ci=False, raise_error=False, local_repo=None)

Reverse acceptance for failed meta data based on a SQL query

This function reverses the acceptance made by the accept() or accept_query() function, based on a SQL query. The arguments are the same as for the accept_query() function.

Parameters
  • meta (str) – The path to the metadata that shall be queried

  • query (str) – The WHERE part of the query (see empd_admin.query.query_samples()).

  • columns (list of str) – The columns that shall not be accepted any more

  • commit (bool) – If True, commit the changes in the repository of meta

  • skip_ci (bool) – If True and commit, then [skip ci] will be added to the commit message

  • raise_error (bool) – If True, raise an error on Failure, otherwise return the error msg

  • local_repo (str) – The path of the local EMPD-data repository. If None, it will be assumed to be the directory of the given meta.

Returns

The status message. None if everything is allright.

Return type

str

See also

unaccept()

Examples

Do not accept any failure for samples where the Country equals “Germany”:

unaccept_query(meta, "Country = 'Germany'", ['Country'])