Пример #1
0
def init(dataset_name):
    """
    Initialize a new dataset at the current dir.
    After init ensure that your data files are in this directory.
    Then you can upload them to Floyd. Example:

        floyd data upload
    """
    dataset_obj = DatasetClient().get_by_name(dataset_name)
    if not dataset_obj:
        create_dataset_base_url = "{}/datasets/create".format(
            floyd.floyd_web_host)
        create_dataset_url = "{}?name={}".format(create_dataset_base_url,
                                                 dataset_name)
        floyd_logger.error(
            ("Dataset name does not match your list of datasets. "
             "Create your new dataset in the web dashboard:\n\t%s"),
            create_dataset_base_url)
        webbrowser.open(create_dataset_url)
        return

    data_config = DataConfig(name=dataset_name, family_id=dataset_obj.id)
    DataConfigManager.set_config(data_config)
    floyd_logger.info(
        "Data source \"{}\" initialized in current directory".format(
            dataset_name))
    floyd_logger.info("""
    You can now upload your data to Floyd by:
        floyd data upload
    """)
Пример #2
0
def init(dataset_name):
    """
    Initialize a new dataset at the current dir.

    Then run the upload command to copy all the files in this
    directory to FloydHub.

        floyd data upload
    """
    dataset_obj = DatasetClient().get_by_name(dataset_name)

    if not dataset_obj:
        namespace, name = get_namespace_from_name(dataset_name)
        create_dataset_base_url = "{}/datasets/create".format(
            floyd.floyd_web_host)
        create_dataset_url = "{}?name={}&namespace={}".format(
            create_dataset_base_url, name, namespace)
        floyd_logger.info(
            ("Dataset name does not match your list of datasets. "
             "Create your new dataset in the web dashboard:\n\t%s"),
            create_dataset_base_url)
        webbrowser.open(create_dataset_url)

        name = click.prompt(
            'Press ENTER to use dataset name "%s" or enter a different name' %
            dataset_name,
            default=dataset_name,
            show_default=False)

        dataset_name = name.strip() or dataset_name
        dataset_obj = DatasetClient().get_by_name(dataset_name)

        if not dataset_obj:
            raise FloydException(
                'Dataset "%s" does not exist on floydhub.com. Ensure it exists before continuing.'
                % dataset_name)

    namespace, name = get_namespace_from_name(dataset_name)
    data_config = DataConfig(name=name,
                             namespace=namespace,
                             family_id=dataset_obj.id)
    DataConfigManager.set_config(data_config)
    floyd_logger.info(
        "Data source \"{}\" initialized in current directory".format(
            dataset_name))
    floyd_logger.info("""
    You can now upload your data to Floyd by:
        floyd data upload
    """)
Пример #3
0
def init(name):
    """
    Initialize a new data upload.
    After init ensure that your data files are in this directory.
    Then you can upload them to Floyd. Example:

        floyd data upload
    """
    data_config = DataConfig(name=name, family_id=generate_uuid())
    DataConfigManager.set_config(data_config)
    floyd_logger.info("Data source \"{}\" initialized in current directory".format(name))
    floyd_logger.info("""
    You can now upload your data to Floyd by:
        floyd data upload
    """)
Пример #4
0
import unittest
from mock import patch
from floyd.manager.data_config import DataConfig
from tests.cli.mocks import mock_access_token, mock_experiment_config

data_config = DataConfig('test_dataset', namespace='pete')


class TestCliUtil(unittest.TestCase):
    """
    Tests cli utils helper functions
    """
    @patch('floyd.manager.experiment_config.ExperimentConfigManager.get_config'
           )
    @patch('floyd.cli.utils.current_username', return_value='pete')
    @patch('floyd.cli.utils.current_dataset_name', return_value='test_dataset')
    @patch('floyd.cli.utils.current_project_name', return_value='my_expt')
    @patch('floyd.cli.utils.DataConfigManager.get_config',
           return_value=data_config)
    def test_normalize_data_name(self, _0, _1, _2, _3, mock_get_config):
        mock_get_config.return_value.namespace = None
        from floyd.cli.utils import normalize_data_name
        assert normalize_data_name('foo/bar/1') == 'foo/datasets/bar/1'
        assert normalize_data_name(
            'foo/datasets/bar/1') == 'foo/datasets/bar/1'
        assert normalize_data_name(
            'foo/bar/1/output') == 'foo/projects/bar/1/output'
        assert normalize_data_name(
            'foo/projects/bar/1/output') == 'foo/projects/bar/1/output'
        # Make sure that the current_username and current_project_name are
        # honored: