Simpler lambda invoke example with AWS SAM cli #3
Conversation
Removed need to specify BAM file anywhere other than invoke Made lambda straight lambda and not 'api gateway' event lambda
Type: AWS::Serverless::Function | ||
Properties: | ||
FunctionName: htsget-aws | ||
Handler: foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does foo bind to the right handler? Or is this value essentially unused for Rust?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a really good question! I guess that for the provided
runtime the handler might not matter because it just goes straight to bootstrap
and then that binary's ELF entrypoint (entry0?)... just guessing though and haven not tested deploy
, just local invoke
... perhaps it does matter in the former?
Right now it prints bytes instead of (base) rvalls@umccr s3-rust-htslib-bam % git diff
diff --git a/src/main.rs b/src/main.rs
index b9f54d1..e132432 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,7 +34,7 @@ async fn bam_header(event: Value, _: Context) -> Result<Value, Error> {
// Get some lowlevel libcurl action on hfile_curl/s3 from htslib and fetch the header
let bam = bam::Reader::from_url(&s3_url).unwrap();
- let header = bam::Header::from_template(bam.header()).to_bytes();
+ let header = bam::Header::from_template(bam.header()).to_hashmap();
// and return the array as a JSON object
Ok(json!(header)) After that, this PR is totally mergeable and super easy to deploy, thanks a lot for all the effort and attention :) |
… did in serverless.com before
src/main.rs
Outdated
return reader.unwrap().target_names(); | ||
// convert the header to an array of strings so we can better see the result | ||
let header_string = String::from_utf8(header.to_bytes()).unwrap(); | ||
let header_strings: Vec<&str> = header_string.split("\n").collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is relatively simple and kind of at least gives the returned JSON object some structure thats meaningful
There appears to be a bug in to_hashmap() for the CRAM files in the example (from a brief look I think the COmment lines are failing to match the expected format in the to_hashmap() regex) "@co\tFASTQ=ERR009378_1.fastq.gz" For the sake of the example I've just changed it to split the header by lines which should be fine as an example.. |
Use lines not split
Thanks a ton for this @andrewpatto :) |
Try to simplify the DX further by using SAM cli. TL;DR is:
Enjoy!