Skip to content

Commit

Permalink
added version number to meta info
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoelles committed Sep 27, 2022
1 parent 42d9289 commit c8a0600
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
Unreleased
-------------

Added
~~~~~~
- added version number to file metadata. If the native file format changes in the future.

Changed
~~~~~~
- using rosbags as ROS library. This avoids the conflicts of the test explorer and dependency on some poorly maintained libraries.
Expand Down
2 changes: 2 additions & 0 deletions pointcloudset/io/dataset/dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
import pandas as pd
from rich import print
import pointcloudset

DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S.%f"
DELIMITER = ";"
Expand Down Expand Up @@ -40,6 +41,7 @@ def dataset_to_dir(
timestamp.strftime(DATETIME_FORMAT) for timestamp in dataset_in.timestamps
]
meta["empty_data"] = empty_data.to_dict()
meta["version"] = pointcloudset.__version__
with open(folder.joinpath("meta.json"), "w") as outfile:
json.dump(dataset_in.meta, outfile)
_check_dir_contents(folder)
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_file_io_dataset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
from pathlib import Path
import json

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -170,6 +171,11 @@ def test_check_dir_file():
def test_check_meta_file(testset: Dataset, tmp_path: Path):
testfile_name = tmp_path.joinpath("dataset0")
testset.to_file(testfile_name, use_orig_filename=False)
meta_in = json.loads(testfile_name.joinpath("meta.json").read_text())
check.equal(
list(meta_in.keys()),
["orig_file", "topic", "timestamps", "empty_data", "version"],
)
testfile_name.joinpath("meta.json").unlink()
with pytest.raises(AssertionError):
dir._check_dir_contents_single(testfile_name)
Expand Down

0 comments on commit c8a0600

Please sign in to comment.