CMR-11242: Adding Toggle for Granule collections Reference validation#2446
CMR-11242: Adding Toggle for Granule collections Reference validation#2446eudoroolivares2016 wants to merge 14 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2446 +/- ##
===========================================
- Coverage 58.20% 28.97% -29.23%
===========================================
Files 1069 1007 -62
Lines 74278 70705 -3573
Branches 2165 1253 -912
===========================================
- Hits 43233 20488 -22745
- Misses 29028 49015 +19987
+ Partials 2017 1202 -815 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| ;; Log the successful ingest, with the metadata size in bytes. | ||
| (api-core/log-concept-with-metadata-size concept-to-log request-context) | ||
| (api-core/generate-ingest-response headers save-granule-result)))) | ||
| ;; (api-core/generate-ingest-response headers save-granule-result) |
| (let [parsed-dif (c/parse-collection all-fields-collection-xml)] | ||
| (is (empty? (v/validate-collection parsed-dif)))))) |
There was a problem hiding this comment.
This was the only place that c/parse-collection was called so its not actually being used in production
| [variable validations-rules] | ||
| (validation-errors->path-errors (v/validate validations-rules variable))) | ||
|
|
||
| (comment (def foo (validation-errors->path-errors (v/validate vg/granule-validation-warnings g1))) |
There was a problem hiding this comment.
Remove the remaining rich comments
| (v/validate (cons vv/variable-validations additional-validations) | ||
| variable)))) | ||
|
|
||
| (defn validate-variable-warnings |
There was a problem hiding this comment.
This wasn't being used at all anywhere
There was a problem hiding this comment.
looks like it is used in umm-spec-lib/src/cmr/umm_spec/validation but it looks like perhaps that func is not being used anywhere either...
| [variable validations-rules] | ||
| (validation-errors->path-errors (v/validate validations-rules variable))) | ||
|
|
||
| (comment (def foo (validation-errors->path-errors (v/validate vg/granule-validation-warnings g1))) |
There was a problem hiding this comment.
Remove the remaining rich comments
| {:default [] | ||
| :parser #(map (comp keyword string/trim) (string/split % #","))}) | ||
|
|
||
| ;; TODO we gotta make sure this is set to true before merging |
There was a problem hiding this comment.
the default is already true, why would it not be true?
Also this is a reminder to remove this ;; TODO comment before merging
| (def ENABLE_UMM_C_VALIDATION_HEADER "cmr-validate-umm-c") | ||
| (def TESTING_EXISTING_ERRORS_HEADER "cmr-test-existing-errors") | ||
| (def COLLECTION_WARNING_CONTEXT "After translating item to UMM-C the metadata had the following issue(s): ") | ||
| (def COLLECTION_ERROR_CONTEXT "After translating item to UMM-C the metadata had the following existing error(s): ") |
There was a problem hiding this comment.
will there ever be a 'regular' error context in the future? If so, renaming this to be COLLECTION_EXISTING_ERROR_CONTEXT could be more beneficial
| #{"[:TemporalExtents 0 :RangeDateTimes 0] BeginningDateTime [2001-01-01T12:00:00.000Z] must be no later than EndingDateTime [2000-05-11T12:00:00.000Z]"}}) | ||
|
|
||
| (format-and-contextualize-warnings-existing-errors foo) | ||
| ) No newline at end of file |
| [cmr.common-app.api.enabled :as common-enabled] | ||
| [cmr.common-app.api.launchpad-token-validation :as lt-validation] | ||
| [cmr.common.log :refer [info]] | ||
| [cmr.common.util :as util] |
There was a problem hiding this comment.
can you make this alphabetical, so move below cmr.common.services.errors
| ;; (api-core/generate-ingest-response headers save-granule-result) | ||
| (api-core/generate-ingest-response headers (util/remove-nil-keys | ||
| (api-core/format-and-contextualize-warnings-existing-errors save-granule-result GRANULE_WARNING_CONTEXT nil) | ||
| )) |
There was a problem hiding this comment.
fix paranthesis formatting
| (vu/has-parent-validator :short-name "Instrument short name") | ||
| (v/every instrument-ref-validations)]}) | ||
| (def ^:private consistency-validations | ||
| "Granule-vs-parent-collection consistency validations. Enforced as errors |
There was a problem hiding this comment.
rename to Granule-vs-parent-collection-consistency-validations or granule-consistency-validations
| set-geometries-spatial-representation | ||
| {:geometries (v/every sv/spatial-validation) | ||
| :orbit (v/when-present sv/spatial-validation)})]) | ||
| ;; The spatial representation has to be set on the geometries before the conversion because |
There was a problem hiding this comment.
is this the right formatting? I would check all the files you changed to see if the indents are correct
| :sensor-refs s-refs | ||
| :operation-modes ["Mode1" "Mode2"]})] | ||
| (g/map->PlatformRef {:short-name plat-short-name | ||
| :instrument-refs [instr-ref]}))) |
| :existing-errors (map str ["e1" "e2"])} | ||
| "W: " "E: ")] | ||
| (is (= ["W: w1;; w2"] (:warnings out))) | ||
| (is (= ["E: e1;; e2"] (:existing-errors out)))))) No newline at end of file |
| ["<example>data</example>"] | ||
| "<example>data</example>"))) | ||
|
|
||
| (deftest format-and-contextualize-warnings-existing-errors-test |
There was a problem hiding this comment.
when you build, make sure this test is actually executed and you see them in the logs
Overview
What is the objective?
This adds a feature toggle which when set to
falsewill allow ingesting granules even if the references between keywords (namely, projects, platforms, instruments, instrument characterists , and operational modes). Instead, those will be returns as warnings from ingest responseWhat are the changes?
Major change: Creating the feature toggle in the
commonas it needed to be used in bothingestand theumm-lib. Threading that up from the validation so that warnings can be propagated down to the end user response.Minor Changes:
Creating the feature toggle in the
commonas it needed to be used in bothingestand theumm-libthere were some additional validation which was dead-code that I am removing. The linter picked up a few changes that I allowed it to leave in there namely spacing. Changing imports to just make this more consistent.What areas of the application does this impact?
Granule ingest and granule validation
Required Checklist
Additional Checklist