Ele 1484 source freshness invocation#1165
Conversation
ELE-1484 Source Freshness Invocation ID
Is your feature request related to a problem? Please describe. Describe the solution you'd like
Describe alternatives you've considered Additional context
Would you be willing to contribute this feature? |
|
👋 @NoyaArie |
|
This PR also covers upload-once-source-freshness-results |
| ) | ||
| select count(*) as count | ||
| from invocations | ||
| where invocation_id = {{ "'" ~ invocation_id ~ "'" }} |
There was a problem hiding this comment.
| where invocation_id = {{ "'" ~ invocation_id ~ "'" }} | |
| where invocation_id = {{ elementary.edr_quote(invocation_id) }} |
| @@ -1,5 +1,5 @@ | |||
| {% macro upload_source_freshness(results) %} | |||
| {% set source_freshness_results_dicts = fromjson(results) %} | |||
| {% set source_freshness_results_dict = fromjson(results) %} | |||
There was a problem hiding this comment.
I think this does take multiple dicts though as target/sources.json:results is a list.
Otherwise it wouldn't work since upload_artifacts_to_table takes a list.
There was a problem hiding this comment.
renaming to source_freshness_results :)
| where invocation_id = {{ "'" ~ invocation_id ~ "'" }} | ||
| {% endset %} | ||
|
|
||
| {% set result = elementary.run_query(query) %} |
| self.upload_results(results) | ||
| click.echo("Uploaded source freshness results successfully.") | ||
| sources_file_contents = self.get_sources_file_contents() | ||
| if sources_file_contents: |
There was a problem hiding this comment.
empty file, which should not happen, but since in the next line accessing to keys prefer checking it
There was a problem hiding this comment.
Personally I would just remove it as this is not something that can happen and this flow is a bit unclear.
If you want to keep it, maybe do:
if not sources_file_contents:
raise raise click.ClickException("Unexpectedly found an empty source.json file.")| @@ -0,0 +1,19 @@ | |||
| {% macro validate_source_freshness_invocation(invocation_id, days_back=14) %} | |||
There was a problem hiding this comment.
Care to rename this macro to something that indicates that it checks whether the source freshness was uploaded or not?
There was a problem hiding this comment.
renaming the macro to can_upload_source_freshness, and the internal variables as well
c48b93f to
a9447b1
Compare
| self.upload_results(results) | ||
| click.echo("Uploaded source freshness results successfully.") | ||
| sources_file_contents = self.get_sources_file_contents() | ||
| if sources_file_contents: |
There was a problem hiding this comment.
Personally I would just remove it as this is not something that can happen and this flow is a bit unclear.
If you want to keep it, maybe do:
if not sources_file_contents:
raise raise click.ClickException("Unexpectedly found an empty source.json file.")| for chunk in upload_with_progress_bar: | ||
| results_segment = results[chunk : chunk + chunk_size] | ||
|
|
||
| for result in results_segment: |
There was a problem hiding this comment.
What's the purpose of this?
There was a problem hiding this comment.
need to pass the metadata to flatten_source_freshness for each record
No description provided.