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

add metadata parsing to batch sample import service #950

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JeffreyThiessen
Copy link
Member

@JeffreyThiessen JeffreyThiessen commented Feb 17, 2025

What does this PR do and why?

Describe in detail what your merge request does and why.

  • additional headers on the spreadsheet for sample imports will be used as metadata.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. seed your db
  2. Start irida next with command line enabled
  3. Sign into User3
  4. navigate to http://localhost:3000/borrelia/borrelia-burgdorferi/outbreak-2024/-/samples
  5. in the file test/fixtures/files/batch_sample_import_with_metadata_valid.csv, edit the project_puid values to match the project we are importing to.
  6. run the following in the terminal to import new samples.
u = User.all[3];n = Project.all[0].namespace;

# replace this path with the path to your irida next git directory
filepath = '/home/CSCScience.ca/jthiessen/git/irida-next-core/test/fixtures/files/batch_sample_import_with_metadata_valid.csv'

blob = ActiveStorage::Blob.create_and_upload!(io: File.open(filepath), filename: 'batch_sample_import_with_metadata_valid.csv')

s = Samples::BatchFileImportService.new(n,u, blob.id, {sample_name_column: 'sample_name', project_puid_column: 'project_puid', sample_description_column: "description"} )

s.execute
  1. You should see 2 new samples added to the project you are viewing, each with 2 metadata fields

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

This comment has been minimized.

@JeffreyThiessen JeffreyThiessen force-pushed the batch_sample_import_service_metadata branch from 4fbf6d7 to 971f660 Compare February 17, 2025 22:39
@JeffreyThiessen JeffreyThiessen marked this pull request as ready for review February 17, 2025 22:40
@JeffreyThiessen JeffreyThiessen added enhancement New feature or request ready for review Pull request is ready for review labels Feb 17, 2025

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

@ksierks ksierks left a comment

Choose a reason for hiding this comment

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

Worked as described. Also tried importing an existing sample & missing project_puid.

@deepsidhu85
Copy link
Contributor

This is looking good but we need to update the activities being attached upon sample import with metadata. Currently it creates an activity for the sample creation and for the update of the sample metadata. We will probably want to pass in a param into the samples create service such as include_activity which we can set to false (the metadata update service already has this setup) and then in the batch sample import service we can create a single activity for the batch import of samples or samples with metadata.

image

@JeffreyThiessen JeffreyThiessen force-pushed the batch_sample_import_service_metadata branch from 51adc1f to 026e218 Compare February 25, 2025 22:50
Copy link

Code Metrics Report

Coverage Test Execution Time
93.1% 11m17s

Code coverage of files in pull request scope (98.5%)

Files Coverage
app/services/samples/batch_file_import_service.rb 98.5%

Reported by octocov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready for review Pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants