Skip to content

Commit 87fab60

Browse files
authored
Merge pull request #29 from ber-data/28-omit-none-valued-fields-from-json-objects-dumped-by-ingester-nmdc
Refine behavior of NMDC ingest script
2 parents 76699c4 + 266e2ad commit 87fab60

File tree

7 files changed

+1311914
-2525233
lines changed

7 files changed

+1311914
-2525233
lines changed

contrib/nmdc/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
# Ignore tool cache directories.
55
/.mypy_cache
66
/.ruff_cache
7+
8+
# Ignore `cache.json` file (commonly-used filename for caching
9+
# the fetched NMDC data between runs of the script).
10+
/cache.json

contrib/nmdc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ graph LR
1010
## Usage
1111

1212
```sh
13-
python ingest.py --help
13+
uv run python ingest.py --help
1414
```
1515

1616
<!--

contrib/nmdc/ingest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def _append_property(slot_definition: SlotDefinition, slot_value: Any) -> None:
264264
self.class_name
265265
):
266266
slot_value = getattr(self, slot_definition.name, None)
267-
if not slot_value:
267+
if slot_value in (None, [], {}):
268268
continue
269269
_append_property(slot_definition, slot_value)
270270

@@ -334,7 +334,7 @@ class Token(str, Enum):
334334
buffer.write(Token.OPEN.value)
335335

336336
# Write this entity to the buffer.
337-
buffer.write(entity.model_dump_json(indent=2))
337+
buffer.write(entity.model_dump_json(exclude_none=True, indent=2))
338338
num_entities_in_buffer += 1
339339

340340
# If either (a) this was the final entity in our list or (b) the buffer size is

0 commit comments

Comments
 (0)