Skip to content

Commit

Permalink
Fix workflow execution completion activities (#791)
Browse files Browse the repository at this point in the history
* starting a migration to remove group activites with workflow keys

* checking if workflow completion service was executed by an automation bot before adding activities

* starting to add public activity checks within the workflow execution completion service

* adding a new test

* fixing translations

* fixing rubocop error

* fixing migration query

* fixing load more button on activities page

* fixing load more button on activities page
  • Loading branch information
ksierks authored Oct 1, 2024
1 parent 4d54e70 commit d80ff3f
Show file tree
Hide file tree
Showing 15 changed files with 273 additions and 11 deletions.
2 changes: 2 additions & 0 deletions app/services/workflow_executions/completion_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def put_output_attachments_onto_samples
end

def create_activities # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
return unless current_user.automation_bot?

@workflow_execution.samples_workflow_executions&.each do |swe|
next if swe.metadata.nil? && swe.outputs.empty?

Expand Down
2 changes: 1 addition & 1 deletion app/views/groups/activity.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= turbo_stream.append "activities" do %>
<% @activities.each do |activity| %>
<%= render Activities::ListItemComponent.new(activity: activity, pagy: @pagy) %>
<%= render Activities::ListItemComponent.new(activity: activity) %>
<% end %>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/activity.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= turbo_stream.append "activities" do %>
<% @activities.each do |activity| %>
<%= render Activities::ListItemComponent.new(activity: activity, pagy: @pagy) %>
<%= render Activities::ListItemComponent.new(activity: activity) %>
<% end %>
<% end %>

Expand Down
8 changes: 4 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ en:
transfer_html: "%{user} transferred project from namespace <span class='font-medium text-slate-800 dark:text-slate-300'>%{old_namespace}</span> to <span class='font-medium text-slate-800 dark:text-slate-300'>%{new_namespace}</span>"
update_html: "%{user} updated project attributes"
workflow_execution:
automated_pipeline_completion:
metadata_written_html: Project automation bot wrote pipeline %{href} metadata to sample %{sample_href}
outputs_and_metadata_written_html: Project automation bot attached pipeline %{href} outputs and wrote metadata to sample %{sample_href}
outputs_written_html: Project automation bot attached pipeline %{href} outputs to sample %{sample_href}
automated_workflow:
create_html: "%{user} setup automated pipeline %{href} for the project"
launch_html: Project automation bot launched pipeline %{href} on sample %{sample_href}
automated_workflow_completion:
metadata_written_html: Project automation bot wrote pipeline %{href} metadata to sample %{sample_href}
outputs_and_metadata_written_html: Project automation bot attached pipeline %{href} outputs and wrote metadata to sample %{sample_href}
outputs_written_html: Project automation bot attached pipeline %{href} outputs to sample %{sample_href}
application:
errors:
access_denied: Access Denied.
Expand Down
8 changes: 4 additions & 4 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ fr:
transfer_html: "%{user} transferred project from namespace <span class='font-medium text-slate-800 dark:text-slate-300'>%{old_namespace}</span> to <span class='font-medium text-slate-800 dark:text-slate-300'>%{new_namespace}</span>"
update_html: "%{user} updated project attributes"
workflow_execution:
automated_pipeline_completion:
metadata_written_html: Project automation bot wrote pipeline %{href} metadata to sample %{sample_href}
outputs_and_metadata_written_html: Project automation bot attached pipeline %{href} outputs and wrote metadata to sample %{sample_href}
outputs_written_html: Project automation bot attached pipeline %{href} outputs to sample %{sample_href}
automated_workflow:
create_html: "%{user} setup automated pipeline %{href} for the project"
launch_html: Project automation bot launched pipeline %{href} on sample %{sample_href}
automated_workflow_completion:
metadata_written_html: Project automation bot wrote pipeline %{href} metadata to sample %{sample_href}
outputs_and_metadata_written_html: Project automation bot attached pipeline %{href} outputs and wrote metadata to sample %{sample_href}
outputs_written_html: Project automation bot attached pipeline %{href} outputs to sample %{sample_href}
application:
errors:
access_denied: Access Denied.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# Migration to remove any activities from a group where an automated workflow key exists
class RemoveGroupActivitiesWithWorkflowKeys < ActiveRecord::Migration[7.2]
def change
PublicActivity::Activity.where(
trackable_id: Group.as_ids,
trackable_type: 'Namespace',
key: ['workflow_execution.automated_workflow_completion.outputs_and_metadata_written',
'workflow_execution.automated_workflow_completion.metadata_written',
'workflow_execution.automated_workflow_completion.outputs_written']
).find_each(&:destroy)
end
end
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/fixtures/files/blob_outputs/normal4/analysis1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
some text in here
1 change: 1 addition & 0 deletions test/fixtures/files/blob_outputs/normal4/analysis2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
and more in here
1 change: 1 addition & 0 deletions test/fixtures/files/blob_outputs/normal4/analysis3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
even more text here
58 changes: 58 additions & 0 deletions test/fixtures/files/blob_outputs/normal4/iridanext.output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"files": {
"global": [
{
"path": "summary.txt"
}
],
"samples": {
"INXT_SAM_AAAAAAAAA3": [
{
"path": "analysis1.txt"
},
{
"path": "analysis2.txt"
}
],
"INXT_SAM_AAAAAAAAA4": [
{
"path": "analysis3.txt"
}
]
}
},
"metadata": {
"samples": {
"INXT_SAM_AAAAAAAAA3": {
"organism": "an organism",
"amr": [
{
"gene": "x",
"start": 1234,
"end": 5678
},
{
"gene": "y",
"start": 1,
"end": 2
}
]
},
"INXT_SAM_AAAAAAAAA4": {
"organism": "a different organism",
"amr": [
{
"gene": "x",
"start": 2345,
"end": 6789
},
{
"gene": "y",
"start": 2,
"end": 3
}
]
}
}
}
}
1 change: 1 addition & 0 deletions test/fixtures/files/blob_outputs/normal4/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a text file.
18 changes: 18 additions & 0 deletions test/fixtures/samples_workflow_executions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ sample42_irida_next_example_completing_f:
"fastq_2": ""
}

sampleA_irida_next_example_completing_g:
sample_id: <%= ActiveRecord::FixtureSet.identify(:sampleA, :uuid) %>
workflow_execution_id: <%= ActiveRecord::FixtureSet.identify(:irida_next_example_completing_g, :uuid) %>
samplesheet_params: {
"sample": INXT_SAM_AAAAAAAAA3,
"fastq_1": <%= "gid://irida/Attachment/#{ActiveRecord::FixtureSet.identify(:attachment1, :uuid)}" %>,
"fastq_2": ""
}

sampleB_irida_next_example_completing_g:
sample_id: <%= ActiveRecord::FixtureSet.identify(:sampleB, :uuid) %>
workflow_execution_id: <%= ActiveRecord::FixtureSet.identify(:irida_next_example_completing_g, :uuid) %>
samplesheet_params: {
"sample": INXT_SAM_AAAAAAAAA4,
"fastq_1": <%= "gid://irida/Attachment/#{ActiveRecord::FixtureSet.identify(:attachment2, :uuid)}" %>,
"fastq_2": ""
}

sample46_irida_next_example_completed_with_output:
sample_id: <%= ActiveRecord::FixtureSet.identify(:sample46, :uuid) %>
workflow_execution_id: <%= ActiveRecord::FixtureSet.identify(:irida_next_example_completed_with_output, :uuid) %>
Expand Down
23 changes: 23 additions & 0 deletions test/fixtures/workflow_executions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,29 @@ irida_next_example_completing_f:
email_notification: true
cleaned: false

irida_next_example_completing_g:
<<: *DEFAULTS
metadata:
{
"workflow_name": "phac-nml/iridanextexample",
"workflow_version": "1.0.2",
}
workflow_params:
{
"input": "/blah/samplesheet.csv",
"outdir": "/blah/output",
}
workflow_engine_parameters: { "-r": "dev" }
workflow_url: "https://github.com/phac-nml/irida_next_example_completed"
run_id: "my_run_id_g"
submitter_id: <%= ActiveRecord::FixtureSet.identify(:projectA_automation_bot, :uuid) %>
namespace_id: <%= ActiveRecord::FixtureSet.identify(:projectA_namespace, :uuid) %>
state: "completing"
blob_run_directory: "not a run dir"
update_samples: true
email_notification: true
cleaned: false

irida_next_example_completed_with_output:
<<: *DEFAULTS
metadata:
Expand Down
Loading

0 comments on commit d80ff3f

Please sign in to comment.