materials_commons.cli.user_config module¶
- class materials_commons.cli.user_config.Config(config_dir_path=None, config_file_name='config.json', override_config={})[source]¶
Bases:
object
Configuration variables
- Order of precedence:
override_config, variables set at runtime
environment variables (both MC_API_URL and MC_API_KEY must be set)
configuration file
default configuration
- Format:
- {
- “default_remote”: {
“mcurl”: <url>, “email”: <email>, “apikey”: <apikey>
}, “remotes”: [
- {
“mcurl”: <url>, “email”: <email>, “apikey”: <apikey>
], “interfaces”: [
- { ‘name’: ‘casm’,
‘desc’:’Create CASM samples, processes, measurements, etc.’, ‘subcommand’:’casm_subcommand’, ‘module’:’casm_mcapi’
], “globus”: {
“transfer_rt”: <token>
}, “developer_mode”: False, “REST_logging”: False, “mcurl”: <url>, # (deprecated) use if no ‘default_remote’ “apikey”: <apikey> # (deprecated) use if no ‘default_remote’
}
- remotes¶
Dict of RemoteConfig, mapping of remote name to RemoteConfig instance
- default_remote¶
RemoteConfig, configuration for default Remote
- interfaces¶
List of InterfaceConfig, settings for software interfaces for the mc CLI program
- globus¶
GlobusConfig, globus configuration settings
- Parameters
config_dir_path – str, path to config directory. Defaults to ~/.materialscommons.
config_file_name – str, name of config file. Defaults to “config.json”.
override_config – dict, config file-like dict, with settings to use instead of those in environment variables or the config file. Defaults to {}.
- class materials_commons.cli.user_config.GlobusConfig(transfer_rt=None, endpoint_id=None)[source]¶
Bases:
object
- class materials_commons.cli.user_config.InterfaceConfig(name=None, module=None, subcommand=None, desc=None)[source]¶
Bases:
object
- class materials_commons.cli.user_config.RemoteConfig(mcurl=None, email=None, mcapikey=None)[source]¶
Bases:
object
- materials_commons.cli.user_config.get_remote_config_and_login_if_necessary(email=None, mcurl=None)[source]¶
Prompt for login if remote is not stored in Config
- Parameters
email (str) – User account email.
mcurl (str) – URL for Materials Commons remote instance. Example: “https://materialscommons.org/api”.
- Returns
user_config.RemoteConfig
– The remote configuration parameters for the provided URL and user account.
- materials_commons.cli.user_config.make_client_and_login_if_necessary(email=None, mcurl=None)[source]¶
Make Client, prompting for login if remote is not stored in Config
- Parameters
email (str) – User account email.
mcurl (str) – URL for Materials Commons remote instance. Example: “https://materialscommons.org/api”.
- Returns
materials_commons.api.Client
– A client for the provided URL and user account.