Skip to content

Commit 553c30a

Browse files
signekblwjohnst86
andauthored
refactor: 🚚 rename obj in package properties script to package_properties (#1484)
# Description When I renamed the template, I forgot to rename the `PackageProperties` object in it to match. This PR does that. This PR needs a quick review. ## Checklist - [X] Added or updated tests - [X] Ran `just run-all` --------- Co-authored-by: Luke W. Johnston <lwjohnst86@users.noreply.github.com>
1 parent 93cc0ba commit 553c30a

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

‎docs/guide/packages.qmd‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ uv run main.py
6969
sp.create_properties_script(package_path.root())
7070
```
7171

72-
This will create a `properties.py` file in the newly created `scripts/`
72+
This will create a `package_properties.py` file in the newly created `scripts/`
7373
folder of your data package.
7474

7575
::: callout-caution
@@ -97,7 +97,7 @@ The file structure should now look like:
9797
print(file_tree(package_path.root()))
9898
```
9999

100-
Inside the `scripts/properties.py` file, you will find a template for
100+
Inside the `scripts/package_properties.py` file, you will find a template for
101101
creating the properties of your data package. It looks like:
102102

103103
```{python}
@@ -126,7 +126,7 @@ is an example of a set of properties with required fields filled in
126126

127127
```{python}
128128
#| eval: false
129-
properties = sp.PackageProperties(
129+
package_properties = sp.PackageProperties(
130130
name="diabetes-study",
131131
title="A Study on Diabetes",
132132
# You can write Markdown below, with the helper `sp.dedent()`.
@@ -175,13 +175,13 @@ So in your `main.py`, include this code:
175175
#| eval: false
176176
#| filename: "main.py"
177177
import seedcase_sprout as sp
178-
from scripts.properties import properties
178+
from scripts.package_properties import package_properties
179179
180180
def main():
181181
# Create the properties script in default location.
182182
sp.create_properties_script()
183183
# Write properties from properties script to `datapackage.json`.
184-
sp.write_properties(properties=properties)
184+
sp.write_properties(properties=package_properties)
185185
186186
if __name__ == "__main__":
187187
main()
@@ -207,7 +207,7 @@ The `write_properties()` function will give an error if the
207207
`PackageProperties` object is missing some of its required fields or if
208208
they are not filled in correctly. In that case, a `datapackage.json`
209209
file won't be created. So you will have to return to the
210-
`scripts/properties.py` file and fill in the correct properties.
210+
`scripts/package_properties.py` file and fill in the correct properties.
211211
:::
212212

213213
The `write_properties()` function created the `datapackage.json` file in
@@ -233,15 +233,15 @@ data package you just created by writing it in the `main.py` file.
233233
#| eval: false
234234
#| filename: "main.py"
235235
import seedcase_sprout as sp
236-
from scripts.properties import properties
236+
from scripts.package_properties import package_properties
237237
238238
def main():
239239
# Create the properties script in default location.
240240
sp.create_properties_script()
241241
# Save the properties to `datapackage.json`.
242-
sp.write_properties(properties=properties)
242+
sp.write_properties(properties=package_properties)
243243
# Create text for a README of the data package.
244-
readme_text = sp.as_readme_text(properties)
244+
readme_text = sp.as_readme_text(package_properties)
245245
# Write the README text to a `README.md` file.
246246
sp.write_file(readme_text, sp.PackagePath().readme())
247247

‎docs/guide/resources.qmd‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ the creation of our resource properties script:
161161
#| filename: "main.py"
162162
#| eval: false
163163
import seedcase_sprout as sp
164-
from scripts.properties import properties
164+
from scripts.package_properties import package_properties
165165
import polars as pl
166166
167167
def main():
@@ -184,9 +184,9 @@ def main():
184184
# New code ends here -----
185185
186186
# Save the properties to `datapackage.json`.
187-
sp.write_properties(properties=properties)
187+
sp.write_properties(properties=package_properties)
188188
# Create text for a README of the data package.
189-
readme_text = sp.as_readme_text(properties)
189+
readme_text = sp.as_readme_text(package_properties)
190190
# Write the README text to a `README.md` file.
191191
sp.write_file(readme_text, sp.PackagePath().readme())
192192
@@ -353,11 +353,11 @@ package. You can do this by adding the following lines to the
353353

354354
```{python}
355355
#| eval: false
356-
#| filename: "properties.py"
356+
#| filename: "package_properties.py"
357357
# Import the resource properties object.
358358
from .resource_properties_patients import resource_properties_patients
359359
360-
properties = sp.PackageProperties(
360+
package_properties = sp.PackageProperties(
361361
# Your existing properties here...
362362
resources=[
363363
resource_properties_patients,
@@ -372,8 +372,8 @@ resource.
372372

373373
The next step is to write the resource properties to the
374374
`datapackage.json` file. Since we included the `resource_properties`
375-
object directly into the `scripts/properties.py` file, and since the
376-
`scripts/properties.py` file is imported already in `main.py`, we can
375+
object directly into the `scripts/package_properties.py` file, and since the
376+
`scripts/package_properties.py` file is imported already in `main.py`, we can
377377
simply re-run the `main.py` file and it will update both the
378378
`datapackage.json` file and the `README.md` file.
379379

‎src/seedcase_sprout/templates/package_properties.py.jinja2‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import seedcase_sprout as sp
22

33
# from .resource_properties import resource_properties
44

5-
properties = sp.PackageProperties(
5+
package_properties = sp.PackageProperties(
66
## Required:
77
name="{{ properties.name }}",
88
title="",

‎tests/test_create_properties_script.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_creates_script_with_default_values(mock_uuid, tmp_cwd):
1919
script_path = create_properties_script()
2020

2121
assert script_path == PackagePath().properties_script()
22-
properties = load_properties(script_path, "properties")
22+
properties = load_properties(script_path, "package_properties")
2323
assert properties == PackageProperties(
2424
name=tmp_cwd.name,
2525
title="",
@@ -36,7 +36,9 @@ def test_works_with_custom_path(tmp_path):
3636
script_path = create_properties_script(tmp_path)
3737

3838
assert script_path == PackagePath(tmp_path).properties_script()
39-
properties = cast(PackageProperties, load_properties(script_path, "properties"))
39+
properties = cast(
40+
PackageProperties, load_properties(script_path, "package_properties")
41+
)
4042
assert properties.name == tmp_path.name
4143

4244

0 commit comments

Comments
 (0)