-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PPPL Department name change from PS&T to Discovery Plasma Science (#1505
) * Re-name PPPL subcommunity Rename "Plasma Science and Technology" sub-community to "Discovery Plasma Science" * Update metadata for PPPL department name changes * Updates to UI and tests * Tested service to update metadata for existing records * Rake task to run that service * Documentation for process in /docs directory * Remove stray require statement
- Loading branch information
Showing
10 changed files
with
219 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
# A service to update metadata across PDC Describe | ||
class WorkUpdateMetadataService | ||
RENAMED_PPPL_SUBCOMMUNITIES = [ | ||
{ | ||
old: "Plasma Science & Technology", | ||
new: "Discovery Plasma Science" | ||
} | ||
].freeze | ||
|
||
# For each renamed pppl subcommunity, traverse all of the works | ||
# and update the value | ||
def self.update_pppl_subcommunities(user, commandline: false) | ||
Work.all.each do |work| | ||
resource_before = work.resource.dup | ||
RENAMED_PPPL_SUBCOMMUNITIES.each do |renamed_subcommunity| | ||
sc = work.resource.subcommunities | ||
next unless sc.include? renamed_subcommunity[:old] | ||
puts "Updating work #{work.id}" if commandline | ||
work.resource.subcommunities = new_subcommunities(sc, renamed_subcommunity) | ||
end | ||
work.save | ||
resource_after = work.resource | ||
resource_compare = ResourceCompareService.new(resource_before, resource_after) | ||
WorkActivity.add_work_activity(work.id, resource_compare.differences.to_json, user.id, activity_type: WorkActivity::CHANGES) | ||
end | ||
end | ||
|
||
# Given a list of subcommunities, and a Hash from RENAMED_PPPL_SUBCOMMUNITIES, | ||
# replace all instances of :old with :new | ||
def self.new_subcommunities(sc, renamed_subcommunity) | ||
new_subcommunities = [] | ||
sc.each do |subcommunity| | ||
new_subcommunities << if subcommunity == renamed_subcommunity[:old] | ||
renamed_subcommunity[:new] | ||
else | ||
subcommunity | ||
end | ||
end | ||
new_subcommunities | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Bulk Metadata Updates | ||
When we have metadata updates that need to be undertaken thoughout the system, this is the process. | ||
|
||
## PPPL Department Name Change | ||
PPPL department names appear in the `subcommunities` field in PDC Describe, because that is how they were labeled in the legacy DataSpace application. | ||
1. Update the UI and tests to reflect the new change | ||
2. Update the change map in `WorkUpdateMetadataService` | ||
3. Test the change locally, and follow regular software release processes | ||
4. Once the updated code is on the server, run the rake task to update any existing records to the new PPPL department name: | ||
``` | ||
bundle exec rake metadata:update_pppl_subcommunities\[YOUR_NETID] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :metadata do | ||
# command line syntax: bundle exec rake metadata:update_pppl_subcommunities\["netid"\] | ||
desc "Update renamed PPPL subcommunities" | ||
task :update_pppl_subcommunities, [:netid] => [:environment] do |_, args| | ||
netid = args[:netid] | ||
user = User.find_by(uid: netid) | ||
raise("No user found for id #{netid}") unless user | ||
WorkUpdateMetadataService.update_pppl_subcommunities(user, commandline: true) | ||
puts "Updated subcommunities metadata, recorded user #{netid} in WorkActivity" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"resource": { | ||
"titles": [ | ||
{ | ||
"title": "Data for \"The value of fusion energy to a decarbonized United States electric grid\"", | ||
"title_type": null | ||
} | ||
], | ||
"description": "Fusion could be a part of future decarbonized electricity systems, but it will need to compete with other technologies. In particular, pulsed tokamaks plants have a unique operational mode, and evaluating which characteristics make them economically competitive can help select between design pathways. Using a capacity expansion and operations model, we determined cost thresholds for pulsed tokamaks to reach a range of penetration levels in a future decarbonized US Eastern Interconnection. The required capital cost to reach a fusion capacity of 100 GW varied from $3000 to $7200/kW, and the equilibrium penetration increases rapidly with decreasing cost. The value per unit power capacity depends on the variable operational cost and on cost of its competition, particularly fission, much more than on the pulse cycle parameters. These findings can therefore provide initial cost targets for fusion more generally in the United States.", | ||
"collection_tags": [ | ||
"Discovery Plasma Science" | ||
], | ||
"creators": [ | ||
{ | ||
"value": "Schwartz, Jacob A.", | ||
"name_type": "Personal", | ||
"given_name": "Jacob A.", | ||
"family_name": "Schwartz", | ||
"identifier": { | ||
"value": "0000-0001-9636-8181", | ||
"scheme": "ORCID", | ||
"scheme_uri": "https://orcid.org" | ||
}, | ||
"affiliations": [], | ||
"sequence": 0 | ||
}, | ||
{ | ||
"value": "Ricks, Wilson", | ||
"name_type": "Personal", | ||
"given_name": "Wilson", | ||
"family_name": "Ricks", | ||
"identifier": null, | ||
"affiliations": [], | ||
"sequence": 1 | ||
}, | ||
{ | ||
"value": "Kolemen, Egemen", | ||
"name_type": "Personal", | ||
"given_name": "Egemen", | ||
"family_name": "Kolemen", | ||
"identifier": { | ||
"value": "0000-0003-4212-3247", | ||
"scheme": "ORCID", | ||
"scheme_uri": "https://orcid.org" | ||
}, | ||
"affiliations": [], | ||
"sequence": 2 | ||
}, | ||
{ | ||
"value": "Jenkins, Jesse D.", | ||
"name_type": "Personal", | ||
"given_name": "Jesse D.", | ||
"family_name": "Jenkins", | ||
"identifier": { | ||
"value": "0000-0002-9670-7793", | ||
"scheme": "ORCID", | ||
"scheme_uri": "https://orcid.org" | ||
}, | ||
"affiliations": [], | ||
"sequence": 3 | ||
} | ||
], | ||
"resource_type": "Dataset", | ||
"resource_type_general": "Dataset", | ||
"publisher": "Princeton University", | ||
"publication_year": "2022", | ||
"doi": "10.34770/f8em-3c49", | ||
"rights_many": [ | ||
{ | ||
"identifier": "CC BY", | ||
"uri": "https://creativecommons.org/licenses/by/4.0/", | ||
"name": "Creative Commons Attribution 4.0 International" | ||
} | ||
], | ||
"version_number": "1", | ||
"related_objects": [], | ||
"keywords": [], | ||
"contributors": [], | ||
"organizational_contributors": [], | ||
"funders": [ | ||
{ | ||
"ror": "https://ror.org/01bj3aw27", | ||
"funder_name": "United States Department of Energy", | ||
"award_number": "DE-AC02-09CH11466", | ||
"award_uri": "" | ||
} | ||
], | ||
"domains": [ | ||
"Natural Sciences" | ||
], | ||
"communities": [ | ||
"Princeton Plasma Physics Laboratory" | ||
], | ||
"subcommunities": [ | ||
"Plasma Science & Technology", | ||
"Fake Subcommunity" | ||
], | ||
"migrated": true | ||
}, | ||
"files": [], | ||
"group": { | ||
"title": "Princeton Plasma Physics Lab (PPPL)", | ||
"description": null, | ||
"code": "PPPL", | ||
"created_at": "2023-09-11T09:17:56.476-04:00", | ||
"updated_at": "2023-09-11T09:17:56.476-04:00" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
|
||
RSpec.describe WorkUpdateMetadataService do | ||
include ActiveJob::TestHelper | ||
context "a PPPL department name change" do | ||
let(:work) { FactoryBot.create :pppl_work_with_department_name_change } | ||
let(:user) { FactoryBot.create :pppl_submitter } | ||
it "renames PPPL subcommunities" do | ||
expect(work.resource.subcommunities).to contain_exactly("Plasma Science & Technology", "Fake Subcommunity") | ||
expect(work.work_activity).to be_empty | ||
described_class.update_pppl_subcommunities(user) | ||
work.reload | ||
expect(work.resource.subcommunities).to contain_exactly("Discovery Plasma Science", "Fake Subcommunity") | ||
expect(work.work_activity.count).to eq 1 | ||
expect(JSON.parse(work.work_activity.last.message)["subcommunities"].first["action"]).to eq "changed" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters