Skip to content

Commit 3db545e

Browse files
authored
refactor: ♻️ match Sprout (#40)
1 parent 8aa160c commit 3db545e

File tree

8 files changed

+364
-735
lines changed

8 files changed

+364
-735
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ gh repo create NAME --template seedcase-project/template-data-package
1414

1515
To add uv:
1616

17-
1. Delete the `pyproject.toml` file.
18-
2. In the terminal run `uv init`.
19-
3. Look at the Git pane and take what was removed and move it over into
17+
1. Delete the `pyproject.toml` file.
18+
2. In the terminal run `uv init`.
19+
3. Look at the Git pane and take what was removed and move it over into
2020
the new `pyproject.toml` file. You can mimic what was done in
2121
`example-seed-beetle` repo.
2222

2323
Then, in the terminal, run:
2424

2525
``` bash
26-
uv add polars pyjanitor
27-
uv add "seedcase-sprout @ git+<https://github.com/seedcase-project/seedcase-sprout>"
26+
uv add polars pyjanitor seedcase-sprout
2827
uv add --dev ruff commitizen pre-commit typos
2928
```
3029

data-raw/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

data-raw/downloaded/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

main.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# import polars as pl
2+
import seedcase_sprout as sp
3+
4+
from scripts.properties import properties
5+
6+
# from scripts.resource_properties import resource_properties
7+
8+
9+
def main():
10+
"""Run the build pipeline of the data package."""
11+
## PROPERTIES
12+
13+
## Create the properties script in default location if it doesn't already exist.
14+
package_path = sp.PackagePath()
15+
sp.create_properties_script()
16+
17+
## Load your raw, but tidy, data into a Polars DataFrame.
18+
# raw_data = pl.read_csv(package_path.root() / "raw" / "data.csv")
19+
## Extract field properties from the data.
20+
# field_properties = sp.extract_field_properties(data=raw_data)
21+
22+
## Create the resource properties script if it doesn't already exist.
23+
# sp.create_resource_properties_script(
24+
# resource_name="",
25+
# fields=field_properties,
26+
# )
27+
28+
## Save the properties to `datapackage.json`.
29+
sp.write_properties(properties=properties)
30+
31+
## README
32+
33+
## Create the README text for the data package.
34+
readme_text = sp.as_readme_text(properties)
35+
## Write the README text to a `README.md` file.
36+
sp.write_file(readme_text, package_path.readme())
37+
38+
## BATCH DATA
39+
40+
## Save the batch data.
41+
# sp.write_resource_batch(
42+
# data=raw_data, resource_properties=resource_properties
43+
# )
44+
45+
## RESOURCE DATA
46+
47+
## Read in all the batch data files for the resource as a list.
48+
# batch_data = sp.read_resource_batches(
49+
# resource_properties=resource_properties
50+
# )
51+
## Join them all together into a single Polars DataFrame.
52+
# joined_data = sp.join_resource_batches(
53+
# data_list=batch_data, resource_properties=resource_properties
54+
# )
55+
## Write the resource data file.
56+
# sp.write_resource_data(
57+
# data=joined_data, resource_properties=resource_properties
58+
# )
59+
60+
61+
if __name__ == "__main__":
62+
main()

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ requires-python = ">=3.12"
1717
dependencies = [
1818
"polars>=1.27.0",
1919
"pyjanitor>=0.31.0",
20-
"seedcase-sprout",
20+
"seedcase-sprout>=0.46.3",
2121
]
2222

2323
[project.urls]
@@ -31,6 +31,3 @@ dev = [
3131
"ruff>=0.11.4",
3232
"typos>=1.32.0",
3333
]
34-
35-
[tool.uv.sources]
36-
seedcase-sprout = { git = "https://github.com/seedcase-project/seedcase-sprout" }

scripts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Processing and build pipeline scripts."""

scripts/properties.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import seedcase_sprout as sp
2+
3+
# from .resource_properties import resource_properties
4+
5+
properties = sp.PackageProperties(
6+
## Required:
7+
name="template-data-package",
8+
title="",
9+
description="",
10+
licenses=[
11+
sp.LicenseProperties(
12+
## Required:
13+
name="",
14+
## Optional:
15+
# path="",
16+
# title="",
17+
),
18+
],
19+
## Optional:
20+
# homepage="",
21+
# contributors=[
22+
# sp.ContributorProperties(
23+
# ## Required:
24+
# title="",
25+
# ## Optional:
26+
# path="",
27+
# email="",
28+
# given_name="",
29+
# family_name="",
30+
# organization="",
31+
# roles=[""],
32+
# ),
33+
# ],
34+
# keywords=[""],
35+
# image="",
36+
# sources=[
37+
# sp.SourceProperties(
38+
# ## Required:
39+
# title="",
40+
# ## Optional:
41+
# path="",
42+
# email="",
43+
# version="",
44+
# ),
45+
# ],
46+
# resources=[
47+
# resource_properties,
48+
# ],
49+
## Autogenerated:
50+
id="108e33ad-33f9-414f-a93c-bfed390be4e6",
51+
version="0.1.0",
52+
created="2025-07-04T15:17:28+01:00",
53+
)

uv.lock

Lines changed: 243 additions & 721 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)