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

Split parser binary out from runner #183

Merged
merged 3 commits into from
Feb 14, 2024
Merged

Split parser binary out from runner #183

merged 3 commits into from
Feb 14, 2024

Conversation

bcspragu
Copy link
Collaborator

Technically, we could have used a single runner binary with two different base images, but that's liable to get confusing quickly, so this PR creates a new parser binary that is mostly just split out from the runner.

It also refactors a few pieces of code we've been copying around:

  • azcreds - Logic for how to authenticate with Azure based on where we're running
  • async - All the business logic for running async tasks, shared between runner + parser

@bcspragu bcspragu marked this pull request as ready for review February 12, 2024 22:43
@bcspragu bcspragu requested a review from gbdubs February 12, 2024 22:43
// NOTE: This code could benefit from some concurrency, but I'm opting not to prematurely optimize.
var out []*task.ParsePortfolioResponseItem
for _, p := range paths {
lineCount, err := countCSVLines(p)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this - in the discussion with RMI on the doc I sent over last week we agreed that any metrics displayed to the user should come from them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Excellent news for you (which you've likely seen at this point): The updated parser code does surface this info, and this is indeed removed there.

return nil
}

// TODO(grady): Move this line counting into the image to prevent having our code do any read of the actual underlying data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Great minds - yeah lets' just remove this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above

(also, not great minds, just one great mind. this is literally your comment, just moved)

case ".ttf":
return pacta.FileType_TTF
default:
return pacta.FileType_UNKNOWN
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a log here for missing cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed we do! The method is kept simple for separation of concern purposes, but we do indeed log an error if the extension is UNKNOWN

async/req.go Outdated
return &task, nil
}

func CreateReportReq() (*task.CreateReportRequest, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Consider renaming these from CreateX to something more like GetXFromEnvVars - it's just odd to see a Create method without any caller-discernable input.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

GC, done

@@ -0,0 +1,71 @@
// Package azcreds provides helpers for getting environment-appropriate credentials.
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is super clear and really well documented. Well done!

@bcspragu bcspragu force-pushed the brandon/parser-binary branch from 55b73bf to 3e2a22b Compare February 14, 2024 18:26
@bcspragu bcspragu force-pushed the brandon/pacta-parse branch from 8a6d15e to 402b0b9 Compare February 14, 2024 18:27
Technically, we could have used a single `runner` binary with two different base images, but that's liable to get confusing quickly, so this PR creates a new `parser` binary that is mostly just split out from the `runner`.

It also refactors a few pieces of code we've been copying around:
- `azcreds` - Logic for how to authenticate with Azure based on where we're running
- `async` - All the business logic for running async tasks, shared between `runner` + `parser`
Since that's what we use locally.
@bcspragu bcspragu changed the base branch from brandon/pacta-parse to main February 14, 2024 18:55
@bcspragu bcspragu force-pushed the brandon/parser-binary branch from 3e2a22b to f47f8a6 Compare February 14, 2024 18:55
@bcspragu bcspragu merged commit 4b3f571 into main Feb 14, 2024
2 checks passed
@bcspragu bcspragu deleted the brandon/parser-binary branch February 14, 2024 18:59
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.

2 participants