Skip to content

Conversation

@andrewmchen
Copy link
Contributor

This is part one of two for the configuration profile feature.

In this part, we add support for writing configurations with different profiles. In the next PR, we will add support for using this profile to authenticate to a Databricks workspace other than the one specified by the DEFAULT profile.

@andrewmchen andrewmchen force-pushed the configure-hosts branch 2 times, most recently from d5733a6 to 8da6681 Compare January 5, 2018 03:55


def _configure_cli_token():
def _configure_cli_token(profile):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it support consolidated shard? I think we need to set workspaceId for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should. The profile here is just to distinguish between different types of configurations. Since the DEFAULT profile already works with consolidated I don't see why other profiles wouldn't.



def _get_api_client():
def profile_option(f):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just document how to create config file? I don't think the command option is that useful for this. As a user I would be fine to copy paste and modify the token.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be useful as well. Regarding the command option, aws configure supports the --profile option so this PR follows this convention.

TEST_USER + '\n' +
TEST_PASSWORD + '\n' +
TEST_PASSWORD + '\n'))
assert DatabricksConfig.fetch_from_fs().host(DEFAULT_SECTION) == TEST_HOST

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have some test that doesn't use DEFAULT_SECTION

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_configure_two_sections should test that behavior.

def test_is_valid_false(self):
databricks_config = config.DatabricksConfig()
assert not databricks_config.is_valid
assert not databricks_config.is_valid(config.DEFAULT_SECTION)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need DEFAULT_SECTION everywhere? Can we simply call assert not databricks_config.is_valid()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the explicit parameter adds some clarity here.

Copy link
Collaborator

@mengxr mengxr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'DEFAULT' is the default profile name. But we should think about whether it should be case sensitive or not. Currently, if I ran databricks configure --profile default, I got

  File "/Users/meng/anaconda2/lib/python2.7/site-packages/databricks_cli-0.4.2-py2.7.egg/databricks_cli/configure/config.py", line 131, in _create_section_if_absent
    self._config.add_section(profile)
  File "/Users/meng/anaconda2/lib/python2.7/ConfigParser.py", line 261, in add_section
    raise ValueError, 'Invalid section name: %s' % section
ValueError: Invalid section name: defaul

@property
def host(self):
return self._config.get(DEFAULT_SECTION, HOST) if self.is_valid else None
def host(self, profile):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems more extensible if we implement a DatabricksConfigProvider class (or Factory) that has def from_profile(profile): method. Then the code changes to

conf = DatabricksConfProvider.from_profile(profile)
api_client = ApiClient(conf)

@andrewmchen andrewmchen merged commit bb544b1 into databricks:master Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants