Esempio n. 1
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
    """)
Esempio n. 2
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
    """)
Esempio n. 3
0
def add(source):
    """
    Create a new dataset version from the contents of a job.

    This will create a new dataset version with the job output.
    Use the full job name: foo/projects/bar/1/code, foo/projects/bar/1/files or foo/projects/bar/1/output
    """
    new_data = DatasetClient().add_data(source)
    print_data([DataClient().get(new_data['data_id'])])
Esempio n. 4
0
def add(source):
    """
    Create data for current dataset from a given source, for example: foo/projects/bar/1/output
    """
    new_data = DatasetClient().add_data(source)
    print_data([DataClient().get(new_data['data_id'])])