Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-4074 - make errEndOfDataset public #2654

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/camera/replaypcd/replaypcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ const (

var (
// model is the model of a replay camera.
model = resource.DefaultModelFamily.WithModel("replay_pcd")
errEndOfDataset = errors.New("reached end of dataset")
model = resource.DefaultModelFamily.WithModel("replay_pcd")

// ErrEndOfDataset represents that the replay sensor has reached the end of the dataset.
ErrEndOfDataset = errors.New("reached end of dataset")
)

func init() {
Expand Down Expand Up @@ -178,7 +180,7 @@ func (replay *pcdCamera) NextPointCloud(ctx context.Context) (pointcloud.PointCl
}

if len(resp.GetData()) == 0 {
return nil, errEndOfDataset
return nil, ErrEndOfDataset
}
replay.lastData = resp.GetLast()

Expand Down
8 changes: 4 additions & 4 deletions components/camera/replaypcd/replaypcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestNextPointCloud(t *testing.T) {
// Confirm the end of the dataset was reached when expected
pc, err := replayCamera.NextPointCloud(ctx)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
test.That(t, pc, test.ShouldBeNil)

err = replayCamera.Close(ctx)
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestLiveNextPointCloud(t *testing.T) {
pc, err := replayCamera.NextPointCloud(ctx)
if i == numPCDFiles {
test.That(t, err, test.ShouldNotBeNil)
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
test.That(t, pc, test.ShouldBeNil)

// Add new files for future processing
Expand Down Expand Up @@ -544,7 +544,7 @@ func TestNextPointCloudTimestamps(t *testing.T) {
// Confirm the end of the dataset was reached when expected
pc, err := replayCamera.NextPointCloud(ctx)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
test.That(t, pc, test.ShouldBeNil)

err = replayCamera.Close(ctx)
Expand Down Expand Up @@ -610,7 +610,7 @@ func TestReconfigure(t *testing.T) {
// Confirm the end of the dataset was reached when expected
pc, err := replayCamera.NextPointCloud(ctx)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
test.That(t, pc, test.ShouldBeNil)

err = replayCamera.Close(ctx)
Expand Down
10 changes: 5 additions & 5 deletions components/camera/replaypcd/replaypcd_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ func resourcesFromDeps(t *testing.T, r robot.Robot, deps []string) resource.Depe
func getNextDataAfterFilter(filter *datapb.Filter, last string) (int, error) {
// Basic component part (source) filter
if filter.ComponentName != "" && filter.ComponentName != "source" {
return 0, errEndOfDataset
return 0, ErrEndOfDataset
}

// Basic robot_id filter
if filter.RobotId != "" && filter.RobotId != "robot_id" {
return 0, errEndOfDataset
return 0, ErrEndOfDataset
}

// Apply the time-based filter based on the seconds value in the start and end fields. Because artifacts
Expand Down Expand Up @@ -274,20 +274,20 @@ func getFile(i, end int) (int, error) {
if i < end {
return i, nil
}
return 0, errEndOfDataset
return 0, ErrEndOfDataset
}

// getCompressedBytesFromArtifact will return an array of bytes from the
// provided artifact path, compressing them using gzip.
func getCompressedBytesFromArtifact(inputPath string) ([]byte, error) {
artifactPath, err := artifact.Path(inputPath)
if err != nil {
return nil, errEndOfDataset
return nil, ErrEndOfDataset
}
path := filepath.Clean(artifactPath)
data, err := os.ReadFile(path)
if err != nil {
return nil, errEndOfDataset
return nil, ErrEndOfDataset
}

var dataBuf bytes.Buffer
Expand Down