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

Handle newly introduced deps (before dvc commit) #2202

Merged
merged 4 commits into from
Aug 17, 2022

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented Aug 17, 2022

1/2 main <- this <- #2203

Related to #2177.

When a dep is first introduced it with be returned under the workspace record in the exp show data like this:

  workspace: {
    baseline: {
      data: {
        ...
        deps: {
          'train.py': {
            hash: null,
            size: null,
            nfiles: null
          },
     ...

This previously made the extension fall over. I have changed the types/code to accommodate this situation. See comments inline for details.

Screenshot

Screen Shot 2022-08-17 at 1 36 33 pm

@mattseddon mattseddon added the bug Something isn't working label Aug 17, 2022
@mattseddon mattseddon self-assigned this Aug 17, 2022
@@ -1 +1,8 @@
export const shortenForLabel = (str: string): string => str.slice(0, 7)
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] This is where the error was happening, you cannot slice null, simply adding an optional chain seemed a little dicey so I have updated the incoming types and flushed out some issues in extension/src/experiments/columns/extract.ts. The resulting function is a complete monstrosity but backwards compatible so I can live with it. Please LMK if you have better ideas... especially for the file name.

changes: !!value && !!branch && branch?.deps?.[path]?.value !== value,
value
const value = shortenForLabel<string | null>(hash)
if (value) {
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] By not collecting null here we end up with the desired output in webview (show ...).

@mattseddon mattseddon marked this pull request as ready for review August 17, 2022 03:47
@mattseddon mattseddon changed the title Handle newly created deps Handle newly introduced deps (before dvc commit) Aug 17, 2022
export const shortenForLabel = <T extends string | null>(
strOrNull: T
): T | string => {
if (typeof strOrNull === 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason not to use a ternary operator?

return typeof strOrNull === 'string' ? strOrNull?.slice(0, 7) : strOrNull

strOrNull: T
): T | string => {
if (typeof strOrNull === 'string') {
return strOrNull?.slice(0, 7)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply check for strOrNull to be truthy instead of checking for the type to be a string? A conditional wouldn't be necessary here.

Copy link
Member Author

Choose a reason for hiding this comment

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

image

Will use a ternary.

@codeclimate
Copy link

codeclimate bot commented Aug 17, 2022

Code Climate has analyzed commit ad9900b and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 96.7% (0.0% change).

View more on Code Climate.

@mattseddon mattseddon merged commit 3847491 into main Aug 17, 2022
@mattseddon mattseddon deleted the handle-uncommitted-deps branch August 17, 2022 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants