BaseDefinition
BaseDefinition
¶
Core shared base definition functionality.
describe: dict[str, None] | None
property
¶
Get the model name, title and description.
- name: Term used for filename and referencing.
- title: Human-readable term used as name.
- description: Detailed description for the model. Reference its objective and use-case.
Returns:
Type | Description |
---|---|
dict[str, None] | None
|
A dictionary with the |
__repr__()
¶
Returns the string representation of the model.
get_citation()
¶
Get the citation as a dictionary.
Raises:
Type | Description |
---|---|
ValueError
|
If no citation has been declared or the build is incomplete. |
Returns:
Type | Description |
---|---|
dict[str, str | dict[str, str]]
|
A dictionary conforming to the CitationModel. |
get_json(hide_uuid=False)
¶
Get the json model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hide_uuid |
bool
|
Hide all UUIDs in the nested JSON output. Mostly useful for validation assertions where the only differences between sources are the UUIDs. |
False
|
Returns:
Type | Description |
---|---|
Json | None
|
Json-conforming output, or None. |
save(directory=None, filename=None, created_by=None, hide_uuid=False)
¶
Save model as a json file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory |
str | None
|
Defaults to working directory |
None
|
filename |
str | None
|
Defaults to model name |
None
|
created_by |
str | None
|
Declare the model creator/updater |
None
|
hide_uuid |
bool
|
Hide all UUIDs in the nested JSON output. |
False
|
Returns:
Type | Description |
---|---|
bool
|
Boolean True if saved. |
set_citation(*, citation)
¶
Update or create the citation.
whyqd is designed to support a research process and ensure citation of the incredible work done by research-based data scientists.
A citation has the following definable fields::
- author: The name(s) of the author(s) (in the case of more than one author, separated by
and
), - title: The title of the work,
- url: The URL field is used to store the URL of a web page or FTP download. It is a non-standard BibTeX field,
- publisher: The publisher's name,
- institution: The institution that was involved in the publishing, but not necessarily the publisher,
- doi: The doi field is used to store the digital object identifier (DOI) of a journal article, conference paper, book chapter or book. It is a non-standard BibTeX field. It's recommended to simply use the DOI, and not a DOI link,
- month: The month of publication (or, if unpublished, the month of creation). Use three-letter abbreviation,
- year: The year of publication (or, if unpublished, the year of creation),
- licence: The terms under which the associated resource are licenced for reuse,
- note: Miscellaneous extra information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
citation |
CitationModel
|
A dictionary conforming to the CitationModel. |
required |
Example
import whyqd as qd
datasource = qd.DataSourceDefinition()
datasource.derive_model(source=SOURCE_DATA, mimetype=MIMETYPE)
citation = {
"author": "Gavin Chait",
"month": "feb",
"year": 2020,
"title": "Portsmouth City Council normalised database of commercial ratepayers",
"url": "https://github.com/whythawk/whyqd/tree/master/tests/data",
"licence": "Attribution 4.0 International (CC BY 4.0)",
}
datasource.set_citation(citation=citation)