Skip to content

Commit

Permalink
feat: add new sdk methods and update existing
Browse files Browse the repository at this point in the history
1. Add new sdk methods for updating default runtime and for getting resource consumption limit.
2. Update create_application to support runtime option.
3. Update list_applications to accept state filter query parameters.

Signed-off-by: Subin Shekhar <subinpc@gmail.com>
  • Loading branch information
subinpc committed Nov 24, 2022
1 parent e01cba8 commit af7fe8d
Show file tree
Hide file tree
Showing 4 changed files with 1,076 additions and 149 deletions.
79 changes: 77 additions & 2 deletions examples/test_ibm_analytics_engine_api_v3_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ def test_replace_instance_default_configs_example(self):

instance_default_configs = ibm_analytics_engine_api_service.replace_instance_default_configs(
instance_id='e64c907a-e82f-46fd-addc-ccfafbd28b09',
body={'key1': 'testString'}
body={
"spark.driver.memory": "8G",
"spark.driver.cores": "2",
}
).get_result()

print(json.dumps(instance_default_configs, indent=2))
Expand All @@ -187,7 +190,10 @@ def test_update_instance_default_configs_example(self):

instance_default_configs = ibm_analytics_engine_api_service.update_instance_default_configs(
instance_id='e64c907a-e82f-46fd-addc-ccfafbd28b09',
body={'key1': 'testString'}
body={
"ae.spark.history-server.cores": "1",
"ae.spark.history-server.memory": "4G",
}
).get_result()

print(json.dumps(instance_default_configs, indent=2))
Expand All @@ -197,6 +203,47 @@ def test_update_instance_default_configs_example(self):
except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_get_instance_default_runtime_example(self):
"""
get_instance_default_runtime request example
"""
try:
print('\nget_instance_default_runtime() result:')
# begin-get_instance_default_runtime

runtime = ibm_analytics_engine_api_service.get_instance_default_runtime(
instance_id='e64c907a-e82f-46fd-addc-ccfafbd28b09'
).get_result()

print(json.dumps(runtime, indent=2))

# end-get_instance_default_runtime

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_replace_instance_default_runtime_example(self):
"""
replace_instance_default_runtime request example
"""
try:
print('\nreplace_instance_default_runtime() result:')
# begin-replace_instance_default_runtime

runtime = ibm_analytics_engine_api_service.replace_instance_default_runtime(
instance_id='e64c907a-e82f-46fd-addc-ccfafbd28b09',
spark_version='3.3'
).get_result()

print(json.dumps(runtime, indent=2))

# end-replace_instance_default_runtime

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_create_application_example(self):
"""
Expand All @@ -206,8 +253,16 @@ def test_create_application_example(self):
print('\ncreate_application() result:')
# begin-create_application

application_details = ApplicationRequestApplicationDetails(
application='/opt/ibm/spark/examples/src/main/python/wordcount.py',
arguments=['/opt/ibm/spark/examples/src/main/resources/people.txt'],
runtime={
'spark_version': '3.3'
}
)
application_response = ibm_analytics_engine_api_service.create_application(
instance_id='e64c907a-e82f-46fd-addc-ccfafbd28b09',
application_details=application_details,
).get_result()

print(json.dumps(application_response, indent=2))
Expand Down Expand Up @@ -299,6 +354,26 @@ def test_get_current_resource_consumption_example(self):
except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_get_resource_consumption_limits_example(self):
"""
get_resource_consumption_limits request example
"""
try:
print('\nget_resource_consumption_limits() result:')
# begin-get_resource_consumption_limits

resource_consumption_limits_response = ibm_analytics_engine_api_service.get_resource_consumption_limits(
instance_id='e64c907a-e82f-46fd-addc-ccfafbd28b09'
).get_result()

print(json.dumps(resource_consumption_limits_response, indent=2))

# end-get_resource_consumption_limits

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_replace_log_forwarding_config_example(self):
"""
Expand Down
Loading

0 comments on commit af7fe8d

Please sign in to comment.