create_resource_properties

Warning

🚧 Sprout is still in active development and evolving quickly, so the documentation and functionality may not work as described and could undergo substantial changes 🚧

core.create_resource_properties(path: Path, properties: ResourceProperties)

Creates a valid properties object for the specified resource.

This function sets up and structures a new resource property by taking the fields given in the properties argument to fill them and prepare them to be added to the datapackage.json file.

Parameters

path : Path

The path to the resource id folder; use path_resource() to provide the correct path or use the output of create_resource_structure().

properties : ResourceProperties

The properties of the resource; must be given as a ResourceProperties object following the Data Package specification. See the ResourceProperties help documentation for details on what can or needs to be filled in.

Returns

ResourceProperties

The properties object, verified and updated.

Raises

NotADirectoryError

If path does not point to a directory.

ExceptionGroup

If there is an error in the properties. A group of CheckErrors, one error per failed check.

Examples

import tempfile
from pathlib import Path

import seedcase_sprout.core as sp

# Create a temporary directory for the example
with tempfile.TemporaryDirectory() as temp_dir:
    temp_path = Path(temp_dir)

    # Create a package and resource structure first
    sp.create_package_structure(path=temp_path)
    sp.create_resource_structure(path=temp_path / "1" / "resources")

    # Create resource properties
    sp.create_resource_properties(
        path=temp_path / "1" / "resources" / "1",
        properties=sp.ResourceProperties(
            name="new-resource-name",
            path="data.parquet",
            title="Resource Title",
            description="This resource contains data about...",
        ),
    )
[PosixPath('/tmp/tmp7v2mbwnu/1/datapackage.json'),
 PosixPath('/tmp/tmp7v2mbwnu/1/README.md'),
 PosixPath('/tmp/tmp7v2mbwnu/1/resources')]
[PosixPath('/tmp/tmp7v2mbwnu/1/resources/1'),
 PosixPath('/tmp/tmp7v2mbwnu/1/resources/1/raw')]
ResourceProperties(name='new-resource-name', path='resources/1/data.parquet', type=None, title='Resource Title', description='This resource contains data about...', sources=None, licenses=None, format=None, mediatype=None, encoding=None, bytes=None, hash=None, dialect=None, schema=None)