Skip to content

Add support for additional resources in DataPackage #1

Description

@asgersvenning

Only the mandatory resources are currently supported (and hardcoded) for trap_schema.datapackage.DataPackage.

  1. The Resource class strictly only supports the three standard resources:

class Resource(SerializableModel):
"""Data Resource.
Arguments:
name: Any.
path: Path or URL to the data file.
profile: [Profile](https://specs.frictionlessdata.io/profiles/) of the resource.
format: The file format of this resource.
encoding: The file encoding of this resource.
schema: URL of the used Camtrap DP Table Schema version (e.g.
`https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0/deployments-table-schema.json`).
"""
name : Literal["deployments", "media", "observations"]
path : Literal["deployments.csv", "media.csv", "observations.csv"]
"""Path or URL to the data file."""
profile : Literal["tabular-data-resource"]
"""[Profile](https://specs.frictionlessdata.io/profiles/) of the resource."""
format : Literal["csv"]
"""The file format of this resource."""
mediatype : Literal["text/csv"]
encoding : Literal["utf-8"]
"""The file encoding of this resource."""
schema : Literal["https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0.2/deployments-table-schema.json", "https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0.2/media-table-schema.json", "https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0.2/observations-table-schema.json"]
"""URL of the used Camtrap DP Table Schema version (e.g.
`https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0/deployments-table-schema.json`)."""

  1. The standard_resources/ get_resource functions only support the standard resources:

def get_resource(type : Literal["deployments", "media", "observations"]):
return Resource(
name=type,
path=f"{type}.csv",
profile="tabular-data-resource",
format="csv",
mediatype="text/csv",
encoding="utf-8",
schema=f"https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0.2/{type}-table-schema.json"
)
def standard_resources():
return [
get_resource("deployments"),
get_resource("media"),
get_resource("observations")
]

  1. The resources field of DataPackage is cannot be changed/is not exposed:

class DataPackage(SerializableModel):
"""Data Package is a simple specification for data access and delivery.
Arguments:
name: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#name).
id: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#id).
created: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#created). Camtrap
DP makes this a required property.
title: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#title). Not to be
confused with the title of the project that originated the package
(`package.project.title`).
contributors: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#contributors).
Camtrap DP makes this a required property and restricts `role` values. Can include
people and organizations.
description: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#description). Not
to be confused with the description of the project that originated the package
(`package.project.description`).
version: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#version).
keywords: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#keywords).
image: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#image).
homepage: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#homepage).
sources: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#sources). Can
include the data management platform from which the package was derived (e.g. Agouti,
Trapper, Wildlife Insights).
licenses: See [Data Package specification](https://specs.frictionlessdata.io/data-package/#licenses). If
provided, Camtrap DP further requires at least a license for the content of the package
and one for the media files.
bibliographicCitation: Bibliographic/recommended citation for the package.
project: Camera trap project or study that originated the package.
coordinatePrecision: Least precise coordinate precision of the `deployments.latitude` and `deployments.longitude` (e.g.
`0.01` for coordinates with a precision of 0.01 and 0.001 degree). Especially relevant
when coordinates have been rounded to protect sensitive species.
spatial: GeoJSON
temporal: Temporal coverage of the package.
taxonomic: Taxonomic coverage of the package, based on the unique `observations.scientificName`.
relatedIdentifiers: Identifiers of resources related to the package (e.g. papers, project pages, derived datasets, APIs,
etc.).
references: List of references related to the package (e.g. references cited in `package.project.description`).
References preferably include a DOI.
"""
resources : list[Resource]=Field(default_factory=standard_resources, init=False)
"""See [Data Package specification](https://specs.frictionlessdata.io/data-package/#resource-information).
Camtrap DP further requires each object to be a [Tabular Data Resource](https://specs.frictionlessdata.io/tabular-data-resource/)
with a specific `name` and `schema`. See [Data](https://camtrap-dp.tdwg.org/data) for the requirements for those resources."""
profile : str=Field(default="https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0.2/camtrap-dp-profile.json", init=False)
"""See [Data Package specification](https://specs.frictionlessdata.io/data-package/#profile). Camtrap
DP further requires this to be the URL of the used Camtrap DP Profile version (e.g.
`https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0/camtrap-dp-profile.json`)."""

But Camtrap DP should support additional optional resources; see https://camtrap-dp.tdwg.org/metadata/#resources

The reasoning behind it being fixed like this for the moment is to reduce friction for users and to minimize the chance of "cheating" the standard validation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions