Last active
June 7, 2022 05:16
-
-
Save randyphoa/9e71d85aac770446cb60b6623065802f to your computer and use it in GitHub Desktop.
Deploy R in online mode - create custom environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a conda config with the require libraries | |
config_yaml = """ | |
name: custom | |
channels: | |
- conda-forge | |
dependencies: | |
- r | |
- libiconv | |
""" | |
with open("config.yaml", "w", encoding="utf-8") as f: | |
f.write(config_yaml) | |
# create a custom software specification | |
# note, you can also create a custom software specificaton using the user interface from Watson Machine Learning. | |
meta_props = {wml_client.package_extensions.ConfigurationMetaNames.NAME: "custom-r", wml_client.package_extensions.ConfigurationMetaNames.TYPE: "conda_yml"} | |
package_ext_details = wml_client.package_extensions.store(meta_props=meta_props, file_path="config.yaml") | |
package_ext_uid = wml_client.package_extensions.get_uid(package_ext_details) | |
meta_props = { | |
wml_client.software_specifications.ConfigurationMetaNames.NAME: "custom-r", | |
wml_client.software_specifications.ConfigurationMetaNames.BASE_SOFTWARE_SPECIFICATION: {"guid": wml_client.software_specifications.get_uid_by_name("runtime-22.1-py3.9")}, | |
} | |
software_spec_details = wml_client.software_specifications.store(meta_props=meta_props) | |
software_spec_uid = wml_client.software_specifications.get_uid(software_spec_details) | |
wml_client.software_specifications.add_package_extension(software_spec_uid, package_ext_uid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment