Skip to content

Commit

Permalink
* removing debug logging
Browse files Browse the repository at this point in the history
* adding frontend dialog to re-run analyzers
  • Loading branch information
jkppr committed Sep 7, 2023
1 parent 4ceaa31 commit 94861c6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
50 changes: 44 additions & 6 deletions timesketch/frontend-ng/src/components/Analyzer/AnalyzerList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ limitations under the License.
icon
color="primary"
:disabled="(timelineSelection.length > 0) ? false : true"
@click="runAnalyzer(analyzer.analyzerName)"
@click="!showRerunIcon(analyzer.analyzerName) ? runAnalyzer(analyzer.analyzerName) : handleReRunDialog(analyzer.analyzerName, analyzer.info.display_name)"
>
<v-icon v-if="!showRerunIcon(analyzer.analyzerName)">
mdi-play-circle-outline
Expand All @@ -64,14 +64,44 @@ limitations under the License.
<td>{{ analyzer.info.description }}</td>
</tr>
</tbody>
<v-dialog v-model="reRunDialog" max-width="515" :retain-focus="false">
<v-card>
<v-card-title>
<v-icon large>mdi-replay</v-icon>
<span class="text-h6 ml-2">Run "{{ reRunDialogAnalyzerDisplayName }}" again?</span>
</v-card-title>
<v-card-text>
<div class="mb-2">
The "{{ reRunDialogAnalyzerDisplayName }}" analyzer was already run on the selected timelines. Do you really want to run it again?
</div>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="primary"
text
@click="reRunDialog = false"
>
cancel
</v-btn>
<v-btn
color="primary"
text
@click="runAnalyzer(reRunDialogAnalyzerName, true); reRunDialog = false"
>
continue
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
</v-simple-table>
</template>

<script>
import ApiClient from '../../utils/RestApiClient'
const LOADING_INDICATOR_DURATION_MS = 3000;
const LOADING_INDICATOR_DURATION_MS = 3000
export default {
props: ['timelineSelection'],
Expand All @@ -83,7 +113,10 @@ export default {
* Analyzers that should show loading indicators. Those are triggered
* analyzers for a duration of LOADING_INDICATOR_DURATION_MS.
*/
loadingAnalyzers: []
loadingAnalyzers: [],
reRunDialog: false,
reRunDialogAnalyzerName: '',
reRunDialogAnalyzerDisplayName: '',
}
},
computed: {
Expand Down Expand Up @@ -117,7 +150,7 @@ export default {
this.triggered.forEach(analyzer => analyzerSet.has(analyzer) ? null : analyzerSet.add(analyzer))
this.resetTriggeredAnalyzers()
return analyzerSet
},
Expand Down Expand Up @@ -145,6 +178,11 @@ export default {
}
},
methods: {
handleReRunDialog(analyzerName, analyzerDisplayName) {
this.reRunDialogAnalyzerName = analyzerName
this.reRunDialogAnalyzerDisplayName = analyzerDisplayName
this.reRunDialog = true
},
isLoading(analyzerName) {
return this.loading.includes(analyzerName)
},
Expand All @@ -155,7 +193,7 @@ export default {
const timelinesSet = this.activeAnalyzerTimelinesMap.get(analyzerName)
return timelinesSet ? timelinesSet.size : 0
},
runAnalyzer(analyzerName) {
runAnalyzer(analyzerName, force = false) {
this.triggeredAnalyzers = [...this.triggeredAnalyzers, analyzerName]
this.loadingAnalyzers = [...this.loadingAnalyzers, analyzerName]
Expand All @@ -167,7 +205,7 @@ export default {
// The loading indicator should stay at least LOADING_INDICATOR_DURATION_MS.
const analyzerTriggeredTime = new Date().getTime()
ApiClient.runAnalyzers(this.sketch.id, this.timelineSelection, [analyzerName])
ApiClient.runAnalyzers(this.sketch.id, this.timelineSelection, [analyzerName], force)
.then((response) => {
let analyses = []
let sessionIds = []
Expand Down
4 changes: 2 additions & 2 deletions timesketch/frontend-ng/src/utils/RestApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ export default {
getAnalyzers(sketchId) {
return RestApiClient.get('/sketches/' + sketchId + '/analyzer/')
},
runAnalyzers(sketchId, timelineIds, analyzers) {
runAnalyzers(sketchId, timelineIds, analyzers, forceRun = false) {
let formData = {
timeline_ids: timelineIds,
analyzer_names: analyzers,
analyzer_force_run: false,
analyzer_force_run: forceRun,
}
return RestApiClient.post('/sketches/' + sketchId + /analyzer/, formData)
},
Expand Down
8 changes: 0 additions & 8 deletions timesketch/lib/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,8 @@ def build_sketch_analysis_pipeline(
sketch = Sketch.query.get(sketch_id)
analysis_session = AnalysisSession(user, sketch)

logger.info("TASKS: Building analysis pipeline for: {0}".format(analyzer_names))
analyzers = manager.AnalysisManager.get_analyzers(analyzer_names)
for analyzer_name, analyzer_class in analyzers:
logger.info("TASKS: running analyzer {0}".format(analyzer_name))
base_kwargs = analyzer_kwargs.get(analyzer_name, {})
searchindex = SearchIndex.query.get(searchindex_id)

Expand Down Expand Up @@ -407,9 +405,6 @@ def build_sketch_analysis_pipeline(
kwargs_list_hash = sha1(
json.dumps(kwargs_list, sort_keys=True).encode("utf-8")
).hexdigest()
logger.info(
"TASKS: kwargs_hash: {0}".format("kwargs_hash: " + kwargs_list_hash)
)

if not analyzer_force_run:
skip_analysis = False
Expand All @@ -421,9 +416,6 @@ def build_sketch_analysis_pipeline(
):
for attribute in past_analysis.get_attributes:
if attribute.value == kwargs_list_hash:
logger.info(
"TASK: hash matched: {}".format(attribute.value)
)
skip_analysis = True
break
if skip_analysis:
Expand Down

0 comments on commit 94861c6

Please sign in to comment.