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

chore: Support Token Provider Mode #2160

Merged
merged 14 commits into from
Feb 28, 2024

Conversation

lhrotk
Copy link
Contributor

@lhrotk lhrotk commented Jan 22, 2024

What changes are proposed in this pull request?

Support token provider auth mode, auto refresh token while job is running.

How is this patch tested?

  • I have written tests (not required for typo or doc fix) and confirmed the proposed feature/bug-fix/change works.

Does this PR change any dependencies?

  • No. You can skip this section.
  • [] Yes. Make sure the dependencies are resolved correctly, and list changes here.

Does this PR add a new feature? If so, have you added samples on website?

  • No. You can skip this section.
  • Yes. Make sure you have added samples following below steps.

@lhrotk
Copy link
Contributor Author

lhrotk commented Jan 22, 2024

/azp run

Copy link

Hey @lhrotk 👋!
Thank you so much for contributing to our repository 🙌.
Someone from SynapseML Team will be reviewing this pull request soon.

We use semantic commit messages to streamline the release process.
Before your pull request can be merged, you should make sure your first commit and PR title start with a semantic prefix.
This helps us to create release messages and credit you for your hard work!

Examples of commit messages with semantic prefixes:

  • fix: Fix LightGBM crashes with empty partitions
  • feat: Make HTTP on Spark back-offs configurable
  • docs: Update Spark Serving usage
  • build: Add codecov support
  • perf: improve LightGBM memory usage
  • refactor: make python code generation rely on classes
  • style: Remove nulls from CNTKModel
  • test: Add test coverage for CNTKModel

To test your commit locally, please follow our guild on building from source.
Check out the developer guide for additional guidance on testing your change.

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lhrotk
Copy link
Contributor Author

lhrotk commented Jan 23, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2024

Codecov Report

Attention: Patch coverage is 38.06452% with 96 lines in your changes are missing coverage. Please review.

Project coverage is 84.16%. Comparing base (345bad9) to head (66fb110).

Files Patch % Lines
...crosoft/azure/synapse/ml/fabric/FabricClient.scala 35.71% 36 Missing ⚠️
...t/azure/synapse/ml/fabric/OpenAITokenLibrary.scala 16.66% 25 Missing ⚠️
...ft/azure/synapse/ml/fabric/FabricTokenParser.scala 0.00% 14 Missing ⚠️
...re/synapse/ml/logging/common/PlatformDetails.scala 36.36% 7 Missing ⚠️
...azure/synapse/ml/services/text/TextAnalytics.scala 50.00% 5 Missing ⚠️
...ure/synapse/ml/services/CognitiveServiceBase.scala 66.66% 3 Missing ⚠️
...soft/azure/synapse/ml/services/openai/OpenAI.scala 60.00% 2 Missing ⚠️
...napse/ml/logging/fabric/CertifiedEventClient.scala 33.33% 2 Missing ⚠️
.../microsoft/azure/synapse/ml/fabric/RESTUtils.scala 0.00% 1 Missing ⚠️
...crosoft/azure/synapse/ml/fabric/TokenLibrary.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2160      +/-   ##
==========================================
- Coverage   84.47%   84.16%   -0.31%     
==========================================
  Files         325      328       +3     
  Lines       16959    17067     +108     
  Branches     1524     1548      +24     
==========================================
+ Hits        14326    14365      +39     
- Misses       2633     2702      +69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lhrotk
Copy link
Contributor Author

lhrotk commented Jan 23, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lhrotk
Copy link
Contributor Author

lhrotk commented Jan 24, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

build.sbt Outdated
@@ -32,6 +32,8 @@ val extraDependencies = Seq(
"org.scalactic" %% "scalactic" % "3.2.14",
"io.spray" %% "spray-json" % "1.3.5",
"com.jcraft" % "jsch" % "0.1.54",
"com.pauldijou" %% "jwt-core" % "3.0.0",
"org.json" % "json" % "20180130",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use existing spray parsing dep please

build.sbt Outdated
@@ -32,6 +32,8 @@ val extraDependencies = Seq(
"org.scalactic" %% "scalactic" % "3.2.14",
"io.spray" %% "spray-json" % "1.3.5",
"com.jcraft" % "jsch" % "0.1.54",
"com.pauldijou" %% "jwt-core" % "3.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have some code that parses jwt, check the certified events logging code

Copy link
Contributor Author

@lhrotk lhrotk Feb 7, 2024

Choose a reason for hiding this comment

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

I didn't find any jwt related code, I am reading this: certified_event, can you point me to the right place

@lhrotk
Copy link
Contributor Author

lhrotk commented Jan 25, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lhrotk
Copy link
Contributor Author

lhrotk commented Jan 26, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lhrotk
Copy link
Contributor Author

lhrotk commented Feb 7, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lhrotk
Copy link
Contributor Author

lhrotk commented Feb 21, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lhrotk
Copy link
Contributor Author

lhrotk commented Feb 22, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

import spray.json.DefaultJsonProtocol.StringJsonFormat

object OpenAITokenLibrary extends SynapseMLLogging with AuthHeaderProvider {
var MLMWCToken = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we try to eliminate this var by making it a def or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need another var to tell it is mwc token or aad token and I think it is strange to change value of another var in def for this var. And also this var is a catched token and will expire sometime while def is called only once, wdyt?

@lhrotk
Copy link
Contributor Author

lhrotk commented Feb 23, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -244,6 +247,19 @@ trait HasOpenAITextParams extends HasOpenAISharedParams {
}
}

trait HasOpenAICognitiveServiceInput extends HasCognitiveServiceInput {
override protected def getCustomAuthHeader(row: Row): Option[String] = {
var providedCustomHeader = getValueOpt(row, CustomAuthHeader)
Copy link
Collaborator

Choose a reason for hiding this comment

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

var

Comment on lines 61 to 66
case _: Exception =>
// Handle MalformedURLException or other exceptions
None
}
case None =>
None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we expect these branches to be triggered ever?


class JwtTokenExpiryMissingException(message: String) extends Exception(message)

class FabricTokenParser(JWToken: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

make all the APIs private or private[ml] if they arent supposed to be used by a end user

@lhrotk
Copy link
Contributor Author

lhrotk commented Feb 26, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mhamilton723
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mhamilton723 mhamilton723 merged commit d5650c9 into microsoft:master Feb 28, 2024
66 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants