Skip to content

Commit

Permalink
chore: refactor cognitive package to services (#2117)
Browse files Browse the repository at this point in the history
* chore: move cognitive namespace to services

* add better redirects

* make find_secret api clearer

* run through black

* fix import

* fix import

* fix import

* foo

* foo

* fix import

* fix import

* fix import

* fix

* fix

* fix

* fixes

* fixes

* fix style

* fixes

* fix

* fix geospatial

---------

Co-authored-by: Ubuntu <marhamil@marhamil-gpu-4.g4sx0fkpramudal1bwadxbpp4c.bx.internal.cloudapp.net>
  • Loading branch information
mhamilton723 and Ubuntu committed Nov 1, 2023
1 parent b0caf2e commit fd00b87
Show file tree
Hide file tree
Showing 146 changed files with 1,081 additions and 922 deletions.
15 changes: 15 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import warnings
import sys
from synapse.ml.services import *

warnings.simplefilter(action="always", category=DeprecationWarning)

# Copy attributes from synapse.ml.services to synapse.ml.cognitive
for attr_name in dir(sys.modules["synapse.ml.services"]):
if not attr_name.startswith("_"):
globals()[attr_name] = getattr(sys.modules["synapse.ml.services"], attr_name)
warnings.warn(
f"Importing '{attr_name}' from 'synapse.ml.cognitive' is deprecated. Use 'synapse.ml.services' instead.",
DeprecationWarning,
stacklevel=2,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/anomaly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.anomaly import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.anomaly' is deprecated. Use 'synapse.ml.services.anomaly' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/bing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.bing import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.bing' is deprecated. Use 'synapse.ml.services.bing' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/face.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.face import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.face' is deprecated. Use 'synapse.ml.services.face' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.form import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.form' is deprecated. Use 'synapse.ml.services.form' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/geospatial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.geospatial import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.geospatial' is deprecated. Use 'synapse.ml.services.geospatial' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/langchain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.langchain import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.langchain' is deprecated. Use 'synapse.ml.services.langchain' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.language import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.openai' is deprecated. Use 'synapse.ml.services.language' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/openai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.openai import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.openai' is deprecated. Use 'synapse.ml.services.openai' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.search import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.search' is deprecated. Use 'synapse.ml.services.search' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/speech.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.speech import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.speech' is deprecated. Use 'synapse.ml.services.speech' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.text import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.text' is deprecated. Use 'synapse.ml.services.text' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/translate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.translate import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.translate' is deprecated. Use 'synapse.ml.services.translate' instead.",
DeprecationWarning,
)
8 changes: 8 additions & 0 deletions cognitive/src/main/python/synapse/ml/cognitive/vision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import warnings
from synapse.ml.services.vision import *

# Raise a deprecation warning for the entire submodule
warnings.warn(
"Importing from 'synapse.ml.cognitive.vision' is deprecated. Use 'synapse.ml.services.vision' instead.",
DeprecationWarning,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if sys.version >= "3":
basestring = str

from synapse.ml.cognitive.bing._BingImageSearch import _BingImageSearch
from synapse.ml.services.bing._BingImageSearch import _BingImageSearch
from synapse.ml.stages import Lambda
from pyspark.ml.common import inherit_doc
from pyspark.sql import SparkSession
Expand All @@ -33,14 +33,14 @@ def setMarketCol(self, value):
@staticmethod
def getUrlTransformer(imageCol, urlCol):
bis = (
SparkSession.builder.getOrCreate()._jvm.com.microsoft.azure.synapse.ml.cognitive.bing.BingImageSearch
SparkSession.builder.getOrCreate()._jvm.com.microsoft.azure.synapse.ml.services.bing.BingImageSearch
)
return Lambda._from_java(bis.getUrlTransformer(imageCol, urlCol))

@staticmethod
def downloadFromUrls(pathCol, bytesCol, concurrency, timeout):
bis = (
SparkSession.builder.getOrCreate()._jvm.com.microsoft.azure.synapse.ml.cognitive.bing.BingImageSearch
SparkSession.builder.getOrCreate()._jvm.com.microsoft.azure.synapse.ml.services.bing.BingImageSearch
)
return Lambda._from_java(
bis.downloadFromUrls(pathCol, bytesCol, concurrency, timeout),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def streamToAzureSearch(df, **options):
jvm = SparkContext.getOrCreate()._jvm
writer = jvm.com.microsoft.azure.synapse.ml.cognitive.search.AzureSearchWriter
writer = jvm.com.microsoft.azure.synapse.ml.services.search.AzureSearchWriter
return writer.stream(df._jdf, options)


Expand All @@ -24,7 +24,7 @@ def streamToAzureSearch(df, **options):

def writeToAzureSearch(df, **options):
jvm = SparkContext.getOrCreate()._jvm
writer = jvm.com.microsoft.azure.synapse.ml.cognitive.search.AzureSearchWriter
writer = jvm.com.microsoft.azure.synapse.ml.services.search.AzureSearchWriter
writer.write(df._jdf, options)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive
package com.microsoft.azure.synapse.ml.services

import com.microsoft.azure.synapse.ml.codegen.Wrappable
import com.microsoft.azure.synapse.ml.core.contracts.HasOutputCol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive
package com.microsoft.azure.synapse.ml.services

case class Rectangle(left: Int, top: Int, width: Int, height: Int)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.anomaly
package com.microsoft.azure.synapse.ml.services.anomaly

import com.microsoft.azure.synapse.ml.cognitive._
import com.microsoft.azure.synapse.ml.cognitive.anomaly.AnomalyDetectorProtocol._
import com.microsoft.azure.synapse.ml.services._
import com.microsoft.azure.synapse.ml.services.anomaly.AnomalyDetectorProtocol._
import com.microsoft.azure.synapse.ml.core.contracts.HasOutputCol
import com.microsoft.azure.synapse.ml.core.schema.DatasetExtensions
import com.microsoft.azure.synapse.ml.io.http.ErrorUtils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.anomaly
package com.microsoft.azure.synapse.ml.services.anomaly

import com.microsoft.azure.synapse.ml.core.schema.SparkBindings
import spray.json.DefaultJsonProtocol._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.anomaly
package com.microsoft.azure.synapse.ml.services.anomaly

import com.microsoft.azure.synapse.ml.build.BuildInfo
import com.microsoft.azure.synapse.ml.codegen.Wrappable
import com.microsoft.azure.synapse.ml.cognitive._
import com.microsoft.azure.synapse.ml.cognitive.anomaly.MADJsonProtocol._
import com.microsoft.azure.synapse.ml.cognitive.vision.HasAsyncReply
import com.microsoft.azure.synapse.ml.services._
import com.microsoft.azure.synapse.ml.services.anomaly.MADJsonProtocol._
import com.microsoft.azure.synapse.ml.services.vision.HasAsyncReply
import com.microsoft.azure.synapse.ml.core.contracts.{HasInputCols, HasOutputCol}
import com.microsoft.azure.synapse.ml.core.env.StreamUtilities.using
import com.microsoft.azure.synapse.ml.core.schema.DatasetExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.anomaly
package com.microsoft.azure.synapse.ml.services.anomaly

import com.microsoft.azure.synapse.ml.core.schema.SparkBindings
import spray.json.{DefaultJsonProtocol, RootJsonFormat}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.bing
package com.microsoft.azure.synapse.ml.services.bing

import com.microsoft.azure.synapse.ml.cognitive._
import com.microsoft.azure.synapse.ml.services._
import com.microsoft.azure.synapse.ml.core.utils.AsyncUtils
import com.microsoft.azure.synapse.ml.logging.{FeatureNames, SynapseMLLogging}
import com.microsoft.azure.synapse.ml.param.ServiceParam
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.bing
package com.microsoft.azure.synapse.ml.services.bing

import com.microsoft.azure.synapse.ml.core.schema.SparkBindings

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.face
package com.microsoft.azure.synapse.ml.services.face

import com.microsoft.azure.synapse.ml.cognitive._
import com.microsoft.azure.synapse.ml.cognitive.vision.HasImageUrl
import com.microsoft.azure.synapse.ml.services._
import com.microsoft.azure.synapse.ml.services.vision.HasImageUrl
import com.microsoft.azure.synapse.ml.logging.{FeatureNames, SynapseMLLogging}
import com.microsoft.azure.synapse.ml.param.ServiceParam
import org.apache.http.entity.{AbstractHttpEntity, StringEntity}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.face
package com.microsoft.azure.synapse.ml.services.face

import com.microsoft.azure.synapse.ml.cognitive.Rectangle
import com.microsoft.azure.synapse.ml.services.Rectangle
import com.microsoft.azure.synapse.ml.core.schema.SparkBindings

case class Face(faceId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.form
package com.microsoft.azure.synapse.ml.services.form

import com.microsoft.azure.synapse.ml.codegen.Wrappable
import com.microsoft.azure.synapse.ml.core.contracts.{HasInputCol, HasOutputCol}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.form
package com.microsoft.azure.synapse.ml.services.form

import com.microsoft.azure.synapse.ml.cognitive._
import com.microsoft.azure.synapse.ml.cognitive.vision.{BasicAsyncReply, HasImageInput, ReadLine}
import com.microsoft.azure.synapse.ml.services._
import com.microsoft.azure.synapse.ml.services.vision.{BasicAsyncReply, HasImageInput, ReadLine}
import com.microsoft.azure.synapse.ml.logging.{FeatureNames, SynapseMLLogging}
import com.microsoft.azure.synapse.ml.param.ServiceParam
import com.microsoft.azure.synapse.ml.stages.UDFTransformer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.form
package com.microsoft.azure.synapse.ml.services.form

import com.microsoft.azure.synapse.ml.cognitive.vision.ReadLine
import com.microsoft.azure.synapse.ml.services.vision.ReadLine
import com.microsoft.azure.synapse.ml.core.schema.SparkBindings
import org.apache.spark.sql.Row
import org.apache.spark.sql.types._
import spray.json.{DefaultJsonProtocol, JsonFormat, RootJsonFormat, _}
import spray.json._

object AnalyzeResponse extends SparkBindings[AnalyzeResponse]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.form
package com.microsoft.azure.synapse.ml.services.form

import com.microsoft.azure.synapse.ml.cognitive._
import com.microsoft.azure.synapse.ml.cognitive.vision.{BasicAsyncReply, HasImageInput}
import com.microsoft.azure.synapse.ml.services._
import com.microsoft.azure.synapse.ml.services.vision.{BasicAsyncReply, HasImageInput}
import com.microsoft.azure.synapse.ml.logging.{FeatureNames, SynapseMLLogging}
import com.microsoft.azure.synapse.ml.param.ServiceParam
import org.apache.http.entity.{AbstractHttpEntity, ByteArrayEntity, ContentType, StringEntity}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.cognitive.form
package com.microsoft.azure.synapse.ml.services.form

import com.microsoft.azure.synapse.ml.core.schema.SparkBindings

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in project root for information.

package com.microsoft.azure.synapse.ml.geospatial
package com.microsoft.azure.synapse.ml.services.geospatial

import com.microsoft.azure.synapse.ml.core.schema.SparkBindings
import spray.json.{DefaultJsonProtocol, RootJsonFormat}
Expand Down

0 comments on commit fd00b87

Please sign in to comment.