List Scripts

get

/api/py-scripts/v1/scripts

Lists the scripts to which the current user has access.

Request

There are no request parameters for this operation.

Back to Top

Response

Supported Media Types

200 Response

List of accessible python scripts.
Body ()
Root Schema : schema
Type: array
Show Source
Nested Schema : EmbedScript
Type: object
Show Source

500 Response

Problem connecting to Broker, executing job or other unexpected error.
Body ()
Root Schema : ComputeContainerException
Type: object
Show Source
Back to Top

Examples

The following example lists the available scripts in the Oracle Machine Learning for Python (OML4Py) script repository. In the example, five scripts are in the repository. All are owned by the user OML_USER.

curl -i -X GET --header "Authorization: Bearer ${token}" \
--header 'Accept: application/json' \
"<oml-cloud-service-location-url>/oml/api/py-scripts/v1/scripts"

Response Headers

The response headers are the following:

HTTP/1.1 200 OK
Date: Thu, 27 Aug 2020 16:14:24 GMT
Content-Type: application/json
Content-Length: 5023
Connection: keep-alive
Cache-Control: no-cache, no-store, private
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1;mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID=node01uxykm5vsa7qy18dif7nd7sabl717.node0; Path=/oml; Secure; HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT

Response Body

The response body in JSON format is the following:

{"result":[
{"owner":"OML_USER","date":"2020-08-27T15:53:56.000Z","name":"return_df","description":null,"script":"def return_df(num, scale):\n    import pandas as pd\n    id = list(range(0, int(num)))\n    res = [i/scale for i in id]\n    return pd.DataFrame({\"ID\":id, \"RES\":res})"},
{"owner":"OML_USER","date":"2020-08-27T16:09:17.000Z","name":"RandomRedDots","description":null,"script":"def RandomRedDots (num_dots_1=100, num_dots_2=10):\n  import numpy as np\n  import pandas as pd\n  import matplotlib.pyplot as plt  \n  d = {'id': range(1,10), 'val': [x/100 for x in range(1,10)]}\n  df = pd.DataFrame(data=d)\n  fig = plt.figure(1)\n  ax = fig.add_subplot(111)\n  ax.scatter(range(0,int(num_dots_1)), np.random.rand(int(num_dots_1)),c='r')\n  fig.suptitle(\"Random Red Dots\")\n  fig2 = plt.figure(2)\n  ax2 = fig2.add_subplot(111)\n  ax2.scatter(range(0,int(num_dots_2)), np.random.rand(int(num_dots_2)),c='r')\n  fig2.suptitle(\"Random Red Dots\")\n  return df"},
{"owner":"OML_USER","date":"2020-08-26T20:38:57.000Z","name":"compute_random_mean","description":null,"script":"def compute_random_mean(index):\n    import numpy as np\n    import scipy\n    from statistics import mean \n    np.random.seed(index)\n    res = np.random.random((100,1))*10\n    return mean(res[1])"},
{"owner":"OML_USER","date":"2020-08-18T21:35:06.000Z","name":"group_count","description":null,"script":"def group_count(dat):\n  import oml\n  import pandas as pd\n  return pd.DataFrame([(dat[\"SPECIES\"][0], dat[\"SEPAL_LENGTH\"][0], dat.shape[0])],   columns = [\"SPECIES\",\"SEPAL_LENGTH\", \"COUNT\"])"},
{"owner":"OML_USER","date":"2020-08-21T18:22:38.000Z","name":"my_predict","description":null,"script":"def my_predict(dat):\n    import pandas as pd\n    import oml\n    obj_dict = oml.ds.load(name=\"ds_regr\", to_globals=False)  \n    regr = obj_dict[\"regr\"]                                 # get the regr model. Ask Qin..can we change this?  Is it technically feasible?\n    pred = regr.predict(dat[['Sepal_Length', \n                             'Sepal_Width',\n                             'Petal_Length']])\n    return pd.concat([dat[['Species', 'Petal_Width']], \n                     pd.DataFrame(pred, \n                                  columns=['Pred_Petal_Width'])], \n                                  axis=1)"},
]}
Back to Top