Repository navigation
Feature/idrs switch - #131
Conversation
|
⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
✅ I finished the code review, and didn't find any security or code quality issues. |
|
@edandylytics tagged you as reviewer for visibility mainly, but lmk if you have any thoughts! |
edandylytics
left a comment
There was a problem hiding this comment.
I haven't tried running locally yet, but thinking tomorrow I'll combine this branch and the one I've got in #128 and see how it shakes out.
| self.error_url = job["appUrls"]["error"] | ||
| self.matches_url = job["appUrls"]["unmatchedIds"] | ||
| self.summary_url = job["appUrls"]["summary"] | ||
| self.idrs_url = job["appUrls"]["identityService"] |
There was a problem hiding this comment.
Note that the app will only send this URL for 'fuzzy' and 'id_based_fuzzy_background' modes -- i.e. when there's an IDRS connection configured and it's ready to be used.
There was a problem hiding this comment.
Also fixed this up thank you for noting
| if self.id_matching_mode in ['fuzzy', 'id_based_fuzzy_background']: | ||
| if self.em_runtime and self.em_runtime <= config.MAX_EM_RUNTIME_SECONDS: | ||
| self.match_candidates() | ||
| self.get_id_matches(artifact.CANDIDATES.path) |
There was a problem hiding this comment.
Why move the fuzzy matching steps to before the id-based processing has finished? Interleaving the processing modes makes me nervous.
I'm not saying it doesn't work, but I'd want to make very sure:
- a new fuzzy matching step failing doesn't break existing id-based matching
- the app gets a coherent set of updates from the Executor (e.g. only one
earthmover_depsevent) - state management between the two processing modes is maintainable long term, since we'll need id-based and fuzzy matching for the foreseeable future (until IDRS becomes a hard requirement to use Runway).
- For example, it looks like
match_candidatesmoves the output directory. Will that interfere with where Lightbeam expects the files from the id-based mode to be?
- For example, it looks like
There was a problem hiding this comment.
I think we should chat about this a bit more tomorrow to make sure I'm understanding. I think some of this might come down to the naming in the executor at the moment.
As written in this PR, the execution flow is:
id_based-> Run our normal process (encapsulated inorchestrate_earthmover)fuzzy-> Run our new process (right now spread out over a few methods but the piece that implements earthmover ismatch_candidates)
Right now, the processes will be separate in the code as written -- The edge case is id_based_fuzzy_background, which we might just want to make another condition in the finally block.
My thought here was that we want to make the "switch" explicit in the execution flow -- run one process OR the other, and afterwards proceed with the rest of the run as normal. I agree with all your concerns, I certainly want to make sure these processes are independent but can coexist within the execution flow. Let me know if I'm misunderstanding anything here!
| self.idrs_url = job["appUrls"]["identityService"] | ||
| self.output_files_url = job["appUrls"]["outputFiles"] | ||
|
|
||
| self.id_matching_mode = job.get("idMatchingMode", True) |
There was a problem hiding this comment.
id_based as the default?
There was a problem hiding this comment.
Fixed up thanks for the note
@edandylytics Sounds great please ping me and let me know! I anticipate a decent amount of stuff will need to be wired up, but my feeling is the structure is there to hit the IDRS and handle matches |
jayckaiser
left a comment
There was a problem hiding this comment.
I've left some questions, but no major concerns. Andy's callout about chunking the posting to IDRS will be an important improvement to make!
|
@jayckaiser Ready for another look when you get a chance! |
| # The URL for the IDRS | ||
| self.identity_url = identity_url | ||
|
|
||
| def validate_candidates(self, candidates: list[dict]) -> None: |
There was a problem hiding this comment.
The IDRS will reject requests with duplicate correlation IDs, and the candidate package doesn't do any deduping. Somewhere, we'll need to weed out duplicates (though I'm not sure this is the place since it'd be mutating the candidates rather than validating them per se...)
There was a problem hiding this comment.
Might be good to grab some time tomorrow morning to talk about this validation/mutation distinction (is this a bigger chunk of work than this PR, I wonder?)
There was a problem hiding this comment.
Sounds good. FWIW, the validation/mutation distinction was sort of offhand.
But one more thing this function (or something) should do: the candidates package adds a record_count key that'll need to be stripped. The IDRS rejects unexpected keys in order to avoid situations where a caller sends data thinking that it is included in the query and it's not actually factored in.
jayckaiser
left a comment
There was a problem hiding this comment.
@theokaufman I've highlighted a couple more fixes that I missed during our one-on-one this week. Let me know if you have any questions!
|
|
||
| resp = self.conn.post( | ||
| url=idrs_conn_info['url'], | ||
| headers={"Authorization": f"Bearer {idrs_conn_info['token']}"}, |
There was a problem hiding this comment.
Do we need to worry about auth-expiry? Will we ever need to refresh this token mid-run?
There was a problem hiding this comment.
I don't think so. We are getting the token in the payload of get_candidates, so it will always be fresh. Any given run that hits the IDRS will use a new token, so I don't think we will need to refresh
There was a problem hiding this comment.
The app ensures there's at least 10 min left before the token expires before handing it to the Executor. But if you do get a 401, you can always request a token again from the app. If the 401 was due to token expiration, you'll get a new one.
|
@edandylytics heads up that this is good to go! |
WIP
Adds in:
Still to come in this or subsequent PRs:
stu-assess-ledgerandunsentartifacts