Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyphemus mvir1 waiver update json #1016

Merged
merged 3 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/archimedes-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /app
ENV DOCKER_VERSION 19.03.12
ENV PYTHON_VERSION 3.8
ENV DOCKERIZE_VERSION 0.5.0
ENV POETRY_VERSION 1.1.4
ENV POETRY_VERSION 1.1.15
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we hit this problem: python-poetry/poetry#6300

So bumping the poetry version.

ENV DOCKERIZE_URL https://github.com/jwilder/dockerize/releases/download/v${DOCKERIZE_VERSION}/dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz
ENV PATH "/app/bin:/opt/poetry/bin:$PATH"
ENV POETRY_HOME "/opt/poetry"
Expand Down
8 changes: 4 additions & 4 deletions polyphemus/lib/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def cascade_to_pool(base_model)

update_request = Etna::Clients::Magma::UpdateRequest.new(project_name: project)
update_request.update_revision("#{base_model}_pool", pool, restricted: true)
magma_client.update(update_request)
magma_client.update_json(update_request)
else
logger.info "#{base_model}_pool #{pool} does not include a restricted patient, relaxing."

Expand All @@ -322,7 +322,7 @@ def cascade_to_pool(base_model)

update_request = Etna::Clients::Magma::UpdateRequest.new(project_name: project)
update_request.update_revision("#{base_model}_pool", pool, restricted: false)
magma_client.update(update_request)
magma_client.update_json(update_request)
end
end
end
Expand All @@ -341,7 +341,7 @@ def restrict!(patient, delete_metis_files: false)
Rollbar.info("Attempting to restrict access to #{name}")
update_request = Etna::Clients::Magma::UpdateRequest.new(project_name: project)
update_request.update_revision('patient', name, restricted: true)
magma_client.update(update_request)
magma_client.update_json(update_request)
end
end

Expand All @@ -362,7 +362,7 @@ def unrestrict!(patient)
Rollbar.info("Attempting to unrestrict access to #{name}")
update_request = Etna::Clients::Magma::UpdateRequest.new(project_name: project)
update_request.update_revision('patient', name, restricted: false)
magma_client.update(update_request)
magma_client.update_json(update_request)
end
end

Expand Down
30 changes: 15 additions & 15 deletions polyphemus/spec/cascade_mvir_restricted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@all_updates = []

WebMock.disable_net_connect!
stub_magma_setup(patients_to_restrict)
stub_magma_setup(patients_to_restrict, use_json: true)
stub_magma_restricted_pools('cytof', ['pool-a', 'pool-c'])
stub_magma_all_pools('cytof', ['pool-a', 'pool-c'])
stub_magma_restricted_pools('sc_rna_seq', ['pool-e', 'pool-f'])
Expand Down Expand Up @@ -53,23 +53,23 @@
acc
end).to eq({
"cytof_pool" => {
"pool-a" => {"restricted" => "true"},
"pool-c" => {"restricted" => "true"}
"pool-a" => {"restricted" => true},
"pool-c" => {"restricted" => true}
},
"sc_rna_seq_pool" => {
"pool-e" => {"restricted" => "true"},
"pool-f" => {"restricted" => "true"},
"pool-e" => {"restricted" => true},
"pool-f" => {"restricted" => true},
},
"patient" => {
"Mike" => {"restricted" => "true"},
"Dan" => {"restricted" => "true"},
"Mike" => {"restricted" => true},
"Dan" => {"restricted" => true},
}
})
end

it 'correctly makes Metis calls to restrict patient and pool folders' do
patients_to_restrict[:Dan][:consent] = 'No Samples/Data'
stub_magma_setup(patients_to_restrict)
stub_magma_setup(patients_to_restrict, use_json: true)

stub_parent_exists({status: 422, bucket: RESTRICT_BUCKET})
stub_create_folder({bucket: RESTRICT_BUCKET})
Expand Down Expand Up @@ -119,7 +119,7 @@

it 'continues working if a single patient throws an error' do
patients_to_restrict[:Dan][:consent] = 'No Samples/Data'
stub_magma_setup(patients_to_restrict)
stub_magma_setup(patients_to_restrict, use_json: true)
stub_parent_exists({status: 422, bucket: RESTRICT_BUCKET})
stub_create_folder({bucket: RESTRICT_BUCKET})
stub_rename_folder_with_error({bucket: RELEASE_BUCKET})
Expand Down Expand Up @@ -176,7 +176,7 @@

WebMock.disable_net_connect!

stub_magma_setup(patients_to_release)
stub_magma_setup(patients_to_release, use_json: true)
stub_magma_restricted_pools('cytof', [])
stub_magma_restricted_pools('sc_rna_seq', [])
stub_magma_all_pools('cytof', ['pool-b', 'pool-d'])
Expand Down Expand Up @@ -210,15 +210,15 @@
acc
end).to eq({
"cytof_pool" => {
"pool-b" => {"restricted" => "false"},
"pool-d" => {"restricted" => "false"},
"pool-b" => {"restricted" => false},
"pool-d" => {"restricted" => false},
},
"sc_rna_seq_pool" => {
"pool-g" => {"restricted" => "false"},
"pool-j" => {"restricted" => "false"},
"pool-g" => {"restricted" => false},
"pool-j" => {"restricted" => false},
},
"patient" => {
"Danielle" => {"restricted" => "false"},
"Danielle" => {"restricted" => false},
}
})
end
Expand Down
10 changes: 7 additions & 3 deletions polyphemus/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ def stub_magma_all_pools(base_model, all_pools)
}.to_json })
end

def stub_magma_setup(patient_documents)
def stub_magma_setup(patient_documents, use_json: false)
stub_request(:post, "#{MAGMA_HOST}/retrieve")
.with(body: hash_including({ project_name: "mvir1", model_name: "patient",
attribute_names: ["name", "consent", "restricted"], record_names: "all" }))
.to_return({ body: {
'models': { 'patient': { 'documents': patient_documents } },
}.to_json })

stub_magma_update("mvir1")
use_json ? stub_magma_update_json : stub_magma_update("mvir1")
end

def stub_magma_update(project_name = nil)
Expand Down Expand Up @@ -344,7 +344,11 @@ def stub_magma_models(fixture: "spec/fixtures/magma_test_models.json")

def stub_magma_update_json
stub_request(:post, /#{MAGMA_HOST}\/update$/)
.to_return({ status: 200, body: {}.to_json, headers: { 'Content-Type': "application/json" } })
.to_return do |request|
params = JSON.parse(request.body)
@all_updates << params["revisions"] if @all_updates && params && params["revisions"]
{ body: "{}", status: 200, headers: { 'Content-Type': "application/json" } }
end
end

def stub_redcap_data(stub = nil)
Expand Down