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

Anonymize config output #625

Merged
merged 8 commits into from
Jan 26, 2024
Merged

Anonymize config output #625

merged 8 commits into from
Jan 26, 2024

Conversation

Grifs
Copy link
Collaborator

@Grifs Grifs commented Jan 17, 2024

Describe your changes

Anonymize configs before outputting them, either to console or file

Add .config.projectDir so we can always access it without always having to pass the path as an argument to functions
Set .config.projectDir to @internalFunctionality so it's never outputted (would defeat the whole purpose)
This could potentially clean up more code, but this is not done yet

What if there is no projectDir set (no viash project file found). We'll still be outputting full paths!

Related issue(s)

Closes #20

Type of Change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New functionality (non-breaking change which adds functionality)
  • Major change (non-breaking change which modifies existing functionality)
  • Minor change (non-breaking change which does not modify existing functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist

Requirements:

  • I have read the CONTRIBUTING doc.
  • I have performed a self-review of my code by checking the "Changed Files" tab.
  • My code follows the code style of this project.

Tests:

  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Documentation:

  • Proposed changes are described in the CHANGELOG.md.
  • I have updated the documentation accordingly.

Test Environment

Add .config.projectDir so we can always access it without always having to pass the path as an argument to functions
Set .config.projectDir to @internalFunctionality so it's never outputted (would defeat the whole purpose)
This could potentially clean up more code, but this is not done yet

What if there is no projectDir set (no viash project file found). We'll still be outputting full paths!
@Grifs Grifs changed the base branch from main to develop January 17, 2024 11:29
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1aa279f) 92.39% compared to head (bf191b2) 92.42%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #625      +/-   ##
===========================================
+ Coverage    92.39%   92.42%   +0.03%     
===========================================
  Files          128      128              
  Lines         3865     3881      +16     
  Branches       623      634      +11     
===========================================
+ Hits          3571     3587      +16     
  Misses         294      294              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Grifs Grifs requested a review from rcannood January 17, 2024 15:00
info: Option[Info] = None,

@internalFunctionality
projectDir: Option[String] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be removed, and we should be using the projectConfig.rootDir (or a renamed version thereof) instead, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely! The base didn't have the ProjectConfig in the (component) config yet. Fixed by merging develop into the branch (together with some other functionality fixes)

@Grifs Grifs force-pushed the anonymize_config_output branch from 6cf03ac to 7ece030 Compare January 24, 2024 21:12
@Grifs Grifs requested a review from rcannood January 24, 2024 23:21
Copy link
Member

@rcannood rcannood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions LGTM!

Minor question about the test :)

Comment on lines 120 to 125
test("anonymizePath with a common path and a trailing slash") {
val basePath = Some(Paths.get("/foo/bar"))
val path = "/foo/bar/baz/test.txt"
val result = IO.anonymizePath(basePath, path)
assert(result == "baz/test.txt")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no trailing slash in this example, or am I mistaken?

Suggested change
test("anonymizePath with a common path and a trailing slash") {
val basePath = Some(Paths.get("/foo/bar"))
val path = "/foo/bar/baz/test.txt"
val result = IO.anonymizePath(basePath, path)
assert(result == "baz/test.txt")
}
test("anonymizePath with a common path and a trailing slash") {
val basePath = Some(Paths.get("/foo/bar/"))
val path = "/foo/bar/baz/test.txt"
val result = IO.anonymizePath(basePath, path)
assert(result == "baz/test.txt")
}

Or

Suggested change
test("anonymizePath with a common path and a trailing slash") {
val basePath = Some(Paths.get("/foo/bar"))
val path = "/foo/bar/baz/test.txt"
val result = IO.anonymizePath(basePath, path)
assert(result == "baz/test.txt")
}
test("anonymizePath with a common path and a trailing slash") {
val basePath = Some(Paths.get("/foo/bar"))
val path = "/foo/bar/baz/test_folder/"
val result = IO.anonymizePath(basePath, path)
assert(result == "baz/test_folder/")
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting that! A refactor went wrong. 😛

@Grifs Grifs merged commit 25e8d91 into develop Jan 26, 2024
9 checks passed
@rcannood rcannood deleted the anonymize_config_output branch January 26, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

viash.yaml contains absolute paths from build host
2 participants