-
Notifications
You must be signed in to change notification settings - Fork 75
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 bpipe authentication with an application name #288
Conversation
with an application name
…bpipe connection with an application name. Description of authenticating a bpipe connection with an app is described in the "Bloomberg API Version 3.x Developers Guide" in section 6.4
Is there a reason to create separate functions for this case? It seems simpler/preferable to incorporate an optional app name into the existing functions. But perhaps I'm missing something - I'm not familiar with the details of Bpipe. |
There were a few reasons that I wrote new functions. Let me first say that I would rate myself as an intermediate level R developer at best. I have not developed full time in over ten years. I developed this because I needed to access bpipe. Now to the reasons 1.) the authenticate C++ function was structurally different enough that I thought it warranted a new function. Those are the structural reasons. I also wanted to isolate my code since I do not consider myself a good package developer. Some of my assumptions above may not have been correct. If these are incorrect please inform me where my knowledge is lacking. |
@alfredkanzler Very cool to this moving forward. I'll take a closer look at the code in the next day or two. @johnlaing Can you give it a spin to run it at your end? |
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.
PR looks great -- could not help myself and edited some whitespace, and also added Al to copyright header for those two files
Tried bringing it in line master by cherry-picking our commit, but it still thinks '8 ahead, 1 behind' so squash merge may be easiest.
Builds and checks cleanly on r-release and r-devel so no CRAN issues expected.
Remaining issue: @johnlaing to review and, if possible, run
R/blpConnect.R
Outdated
con <- blpConnect_Impl(host, port, NULL) | ||
} else { | ||
con <- blpConnect_Impl(host, port, app_name) | ||
} |
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.
Here the if (is.null(...))
and else
branches could be collapsed into one which might be simpler. Yet this is clear.
Or it might be better to change it to two lines including one comment that null/non-null is handled at the C(++) level?
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.
I think this is a good point. I can make the change on Monday. I like the simplification with a note in the documentation.
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.
Sounds good! The code is in great shape but I want to hear from @johnlaing too.
src/authenticate.cpp
Outdated
if(uuid_ == R_NilValue) { | ||
identity_p = authenticateWithApp(con_); | ||
} | ||
else { |
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.
I think we put our else on the same line but hey...
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.
More than happy to follow your preferred format. Since I am going to make the change above I will make the change here.
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.
See the 'Outdated' tag :) While I was at it I pushed some trivial changes back to your branch. So make sure you pull on Monday.
} | ||
else { | ||
identity_p = authenticateWithId(con_, uuid_, ip_address_); | ||
} |
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.
I like the simpler switch here and the hand-off to these two specialised functions with the old default and new add-on. Nicely done.
This broke my connectivity right off the bat. I'm going to have to dig in here and figure out what's happening. Bear with me... |
Can you send me how you connect? I will also dig into why it failed. |
This was just a SAPI connection, so specifying host/port. |
R/blpConnect.R
Outdated
##' via \code{blpAuthenticate} after \code{blpConnect}. | ||
##' @examples | ||
##' \dontrun{ | ||
##' con <- blpConnect() # adjust as needed | ||
##' } | ||
blpConnect <- function(host=getOption("blpHost", "localhost"), | ||
port=getOption("blpPort", 8194L), | ||
default=TRUE) { | ||
default=TRUE, | ||
app_name = getOption("blpAppName", NULL)) { |
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.
Stylistic nitpick: we should use something other than snake_case for argument names. We've tended toward camelCase in most functions, thought there are also a few old-school R dot.separated names left over. I think appName
fits best here.
src/blpConnect.cpp
Outdated
// [[Rcpp::export]] | ||
SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_) { | ||
Session* sp = NULL; | ||
if (app_name_ == NULL) { |
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.
I think this should be R_NilValue
rather than NULL
. That seems to be what was killing my connection yesterday.
I missed fixing this. I will make the change and change to camel case. I should have this done today. |
updated documentation and removed redundant code
clarification of appName usage.
Previously tested this with == NULL.
I changed to camel case in the R code. I also think the bug is fixed. John should test. |
Bug is fixed! This is great, thanks for your work. Just a couple other cleanup items from me:
I can take care of these easily on my end. And if we're all in agreement I can push back to your branch, Al, for one more quick test before merging. |
This is good news. I unfortunately cannot test today. I will try to get setup to test tomorrow. |
I made some teeny edits to ChangeLog (and DESCRIPTION) and resolved the merge conflict. Let's do the one final test and then it should be good to go to the repo ... and CRAN! |
Works for me. No need to rush this now that we did it so well. |
I just completed testing without any issues in my tests. |
No objections from me |
@johnlaing All green from your end too? |
All good here, in the sense that the code works. My preference is to always maintain commit history unless there's a very good reason to squash. |
Ace. Will merge and release to CRAN (this eve or tomorrow eve). I'll probably call it 0.4.0 for good measure.
Yes, understood. It is a trade-off. In a squash the log of the individual commits become part of the one commit's log. So not erased, just a wee bit less visible. The upside is the saner graph. With a lot of concurrent activity those become harder to use. |
Bloomberg's bpipe api allows authentication with an application name as described in "Bloomberg API Version 3.x Developers Guide" (https://data.bloomberglp.com/labs/sites/2/2014/07/blpapi-developers-guide-2.54.pdf) section 6.4.
Added functions to support this form of authentication. Please send questions to [email protected].