Skip to content

Commit

Permalink
adding AML Jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Zocca committed Jun 24, 2023
1 parent 1245d5e commit 000cafa
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions ms-azure-api/src/MSAzureAPI/MachineLearning/Jobs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import Control.Applicative (Alternative(..))
import Control.Monad.IO.Class (MonadIO(..))
import Data.Foldable (asum)
import Data.Functor (void)
import Data.Maybe (listToMaybe)
import qualified Text.ParserCombinators.ReadP as RP (ReadP, readP_to_S, choice, many, between, char, string, satisfy)
-- import Data.Maybe (listToMaybe)
import GHC.Generics (Generic(..))

-- aeson
import qualified Data.Aeson as A (ToJSON(..), genericToEncoding, FromJSON(..), genericParseJSON, defaultOptions, Options(..), withObject, withText, (.:), (.:?), object, (.=), Key, Value, camelTo2)
-- bytestring
import qualified Data.ByteString as BS (ByteString)
import qualified Data.ByteString.Char8 as BS8 (pack, unpack)
Expand All @@ -19,31 +21,42 @@ import Network.HTTP.Req (Req, Url, Option, Scheme(..), header, (=:))
-- text
import Data.Text (Text, pack, unpack)
import qualified Data.Text.Lazy as TL (Text, pack, unpack, toStrict)
-- time
import Data.Time (UTCTime, getCurrentTime)
import Data.Time.Format (FormatTime, formatTime, defaultTimeLocale)
import Data.Time.LocalTime (getZonedTime)
-- xeno
import qualified Xeno.DOM.Robust as X (Node, Content(..), name, contents, children)
-- xmlbf-xeno
import qualified Xmlbf.Xeno as XB (fromRawXml)
-- -- time
-- import Data.Time (UTCTime, getCurrentTime)
-- import Data.Time.Format (FormatTime, formatTime, defaultTimeLocale)
-- import Data.Time.LocalTime (getZonedTime)
-- -- xeno
-- import qualified Xeno.DOM.Robust as X (Node, Content(..), name, contents, children)
-- -- xmlbf-xeno
-- import qualified Xmlbf.Xeno as XB (fromRawXml)
-- xmlbf
import qualified Xmlbf as XB (Parser, runParser, pElement, pText)

import MSAzureAPI.Internal.Common (APIPlane(..), (==:), put, get, getBs, post, getLbs)
import qualified MSAzureAPI.Internal.Common as MSA (APIPlane(..), (==:), put, get, getBs, post, getLbs, aesonOptions)



-- | create a job
--
-- docs: <https://learn.microsoft.com/en-us/rest/api/azureml/2023-04-01/jobs/create-or-update?tabs=HTTP>
--
-- @PUT https:\/\/management.azure.com\/subscriptions\/{subscriptionId}\/resourceGroups\/{resourceGroupName}\/providers\/Microsoft.MachineLearningServices\/workspaces\/{workspaceName}\/jobs\/{id}?api-version=2023-04-01@

createJob :: (A.FromJSON b) =>
Text -- ^ subscription id
-> Text -- ^ res group id
-> Text -- ^ ML workspace id
-> Text -- ^ job id
-> JobBase
-> AccessToken -> Req b
createJob sid rgid wsid jid =
put APManagement ["subscriptions", sid,
MSA.put MSA.APManagement ["subscriptions", sid,
"resourceGroups", rgid,
"providers", "Microsoft.MachineLearningServices",
"workspaces", wsid,
"jobs", jid] ("api-version" ==: "2023-04-01")
"jobs", jid] ("api-version" MSA.==: "2023-04-01")

data JobBase = JB
data JobBase = JB {
jbTODO :: Text
} deriving (Eq, Show, Generic)
instance A.ToJSON JobBase where
toEncoding = A.genericToEncoding (MSA.aesonOptions "jb")

0 comments on commit 000cafa

Please sign in to comment.