Esempio n. 1
0
def login_clicked(ui):
    """Checks credentials and permissions and logs in to the AWS account"""

    access_key = ui.access_line_edit.text()
    secret_key = ui.secret_line_edit.text()
    if access_key == "" or secret_key == "":
        login_error("Please enter your programmatic access keys")
    else:
        logged_in, error_name, error_text = aws_login(access_key, secret_key)
        if logged_in:
            ui.access_key = access_key
            ui.secret_key = secret_key
            ui.session = boto3.Session(aws_access_key_id=access_key,
                                       aws_secret_access_key=secret_key)
            call_worker(lambda: populate_regions(ui), ui,
                        ui.select_region_page, "Logging in..")
        else:
            if error_name == "connection_error":
                login_error(
                    "Can't connect to AWS, please check your internet connection."
                )
            elif error_name == 'invalid_access':
                login_error("Invalid login credentials.")
            else:
                login_error("Unexpected error occurred. " + error_text)
Esempio n. 2
0
def related_time_series_clicked(ui):
    ui.current_dataset_type = 'RELATED'
    ui.back_dataset_page = ui.create_related_dataset_page
    if ui.related_dataset_exists:
        # TODO here
        pass
    else:
        call_worker(lambda: create_new_related_dataset_page_selected(ui), ui,
                    ui.create_related_dataset_page, 'Loading..')
Esempio n. 3
0
def metadata_clicked(ui):
    ui.current_dataset_type = 'METADATA'
    ui.back_dataset_page = ui.create_metadata_dataset_page
    if ui.metadata_dataset_exists:
        # TODO here
        pass
    else:
        call_worker(lambda: create_new_metadata_dataset_page_selected(ui), ui,
                    ui.create_metadata_dataset_page, 'Loading..')
Esempio n. 4
0
def target_time_series_clicked(ui):
    ui.current_dataset_type = 'TARGET'
    ui.back_dataset_page = ui.create_target_dataset_page
    if ui.target_dataset_exists:
        # TODO here
        pass
    else:
        call_worker(lambda: create_new_target_dataset_page_selected(ui), ui,
                    ui.create_target_dataset_page, 'Loading..')
Esempio n. 5
0
def dataset_page_selected(ui):
    call_worker(lambda: populate_datasets(ui), ui, ui.select_ds_page,
                'Loading..')
Esempio n. 6
0
def merge_related_clicked(ui):
    csv_file_name = QFileDialog.getOpenFileName(filter="csv(*.csv)")[0]
    ui.merge_csv_file_name = csv_file_name
    call_worker(lambda: merge_csv_page_selected(ui), ui, ui.merge_csv_page,
                "Loading..")
Esempio n. 7
0
def dataset_page_next_clicked(ui):
    dataset_type = ui.current_dataset_type
    ui.new_dataset_name_line_edit.clear()
    call_worker(lambda: prepare_data(ui, dataset_type), ui,
                ui.new_dataset_name_page, "Processing your data, please wait")
Esempio n. 8
0
def buttons_connector(ui):
    # Login Page Connectors
    ui.login_button.clicked.connect(lambda: login_clicked(ui))
    ui.access_line_edit.returnPressed.connect(ui.login_button.click)
    ui.secret_line_edit.returnPressed.connect(ui.login_button.click)

    # Region Page Connectors
    ui.list_region.itemClicked.connect(lambda: region_selected(ui))
    ui.select_region_pb.clicked.connect(lambda: call_worker(
        lambda: dataset_group_page_selected_worker(ui), ui, ui.
        select_ds_group_page, 'Retrieving your dataset groups..'))

    # Dataset Groups Page Connectors
    ui.list_ds_group.itemClicked.connect(lambda: dataset_group_selected(ui))
    ui.select_ds_group_pb.clicked.connect(lambda: dataset_page_selected(ui))
    ui.create_ds_group.clicked.connect(
        lambda: change_current_page(ui, ui.create_ds_page))
    ui.back_ds_group_pb.clicked.connect(
        lambda: change_current_page(ui, ui.select_region_page))

    # Create New Dataset Group Page Connectors
    ui.new_dataset_group_name_line_edit.textChanged[str].connect(
        lambda: ui.create_new_dataset_group_pb.setEnabled(
            ui.new_dataset_group_name_line_edit.text() != ""))
    ui.create_new_dataset_group_pb.clicked.connect(lambda: call_worker(
        lambda: new_dataset_group_create_clicked_worker(ui), ui, ui.
        select_ds_group_page, "Creating dataset group.."))
    ui.back_new_dataset_group_pb.clicked.connect(
        lambda: call_worker(lambda: populate_dataset_groups(ui), ui, ui.
                            select_ds_group_page, 'Loading..'))

    # Datasets Page Connectors
    ui.datasets_view_forecasts_pb.clicked.connect(
        lambda: call_worker(lambda: populate_forecasts(ui), ui, ui.
                            select_forecast_page, 'Loading..'))
    ui.datasets_create_forecasts_pb.clicked.connect(
        lambda: call_worker(lambda: clear_create_new_forecast_page(ui), ui, ui.
                            create_forecast_page, 'Loading..'))
    ui.datasets_back_pb.clicked.connect(
        lambda: call_worker(lambda: populate_dataset_groups(ui), ui, ui.
                            select_ds_group_page, "Loading.."))
    ui.target_time_series_pb.clicked.connect(
        lambda: target_time_series_clicked(ui))
    ui.related_time_series_pb.clicked.connect(
        lambda: related_time_series_clicked(ui))
    ui.item_metadata_pb.clicked.connect(lambda: metadata_clicked(ui))

    # Crete New Target Dataset Page Connectors
    ui.target_select_csv_pb.clicked.connect(
        lambda: select_csv_file(ui, 'TARGET'))
    ui.target_back_new_dataset_pb.clicked.connect(
        lambda: dataset_page_selected(ui))
    ui.target_next_new_dataset.clicked.connect(
        lambda: dataset_page_next_clicked(ui))
    ui.target_item_id_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.target_timestamp_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.target_demand_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.target_location_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))

    # Create New Metadata Dataset Page Connectors
    ui.metadata_select_csv_pb.clicked.connect(
        lambda: select_csv_file(ui, 'METADATA'))
    ui.metadata_back_new_dataset_pb.clicked.connect(
        lambda: dataset_page_selected(ui))
    ui.metadata_next_new_dataset.clicked.connect(
        lambda: dataset_page_next_clicked(ui))
    ui.metadata_item_id_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.metadata_color_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.metadata_category_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.metadata_brand_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))

    # Create New Related Dataset Page Connectors
    ui.related_select_csv_pb.clicked.connect(
        lambda: select_csv_file(ui, 'RELATED'))
    ui.related_back_new_dataset_pb.clicked.connect(
        lambda: dataset_page_selected(ui))
    ui.related_next_new_dataset.clicked.connect(
        lambda: dataset_page_next_clicked(ui))
    ui.related_item_id_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.related_timestamp_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.related_price_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.related_weather_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.related_promotion_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.related_location_combobox.currentTextChanged.connect(
        lambda: are_data_attributes_different(ui))
    ui.related_merge_pb.clicked.connect(lambda: merge_related_clicked(ui))

    # Merge Page Connectors
    ui.merge_merge_pb.clicked.connect(
        lambda: call_worker(lambda: merge_button_clicked(ui), ui, ui.
                            create_related_dataset_page, "Loading.."))

    # Select Name and Frequency Page Connectors
    ui.dataset_name_create_pb.clicked.connect(
        lambda: call_worker(lambda: upload_and_create_dataset(ui), ui))
    ui.dataset_name_back_pb.clicked.connect(
        lambda: change_current_page(ui, ui.back_dataset_page))
    ui.new_dataset_name_line_edit.textChanged[str].connect(
        lambda: ui.dataset_name_create_pb.setEnabled(dataset_name_valid(ui)))
    ui.dataset_frequency_unit_combobox.currentIndexChanged.connect(
        lambda: check_frequency_accuracy(ui, 'DATASET'))

    # Create Forecast Page Connectors
    ui.advanced_forecast_pb.clicked.connect(
        lambda: change_current_page(ui, ui.advanced_settings_page))
    ui.back_new_predictor.clicked.connect(lambda: dataset_page_selected(ui))
    ui.new_forecast_line_edit.textChanged[str].connect(
        lambda: ui.create_new_predictor.setEnabled(forecast_name_valid(ui)))
    ui.create_new_predictor.clicked.connect(
        lambda: call_worker(lambda: create_predictor_and_forecast(ui), ui, ui.
                            select_forecast_page, 'Loading..'))
    ui.create_new_predictor_advanced.clicked.connect(
        lambda: call_worker(lambda: create_predictor_and_forecast(ui), ui, ui.
                            select_forecast_page, 'Loading..'))
    ui.forecast_frequency_unit_combobox.currentIndexChanged.connect(
        lambda: check_frequency_accuracy(ui, 'FORECAST'))

    # Advanced Create Forecast Page Connectors
    ui.back_new_predictor_advanced.clicked.connect(
        lambda: change_current_page(ui, ui.create_forecast_page))
    ui.auto_ml_checkbox.stateChanged.connect(
        lambda: algorithm_checkbox_changed(ui))
    ui.country_checkbox.stateChanged.connect(
        lambda: country_checkbox_changed(ui))
    ui.new_forecast_line_edit.textChanged[str].connect(
        lambda: ui.create_new_predictor_advanced.setEnabled(
            forecast_name_valid(ui)))
    # Forecasts Page Connectors
    ui.list_forecast.itemClicked.connect(lambda: forecast_selected(ui))
    ui.datasets_forecast_pb.clicked.connect(lambda: dataset_page_selected(ui))
    ui.select_forecast_pb.clicked.connect(
        lambda: call_worker(lambda: populate_forecast_view(ui), ui, ui.
                            forecast_view_page, 'Loading'))
    ui.create_forecast_pb.clicked.connect(
        lambda: call_worker(lambda: clear_create_new_forecast_page(ui), ui, ui.
                            create_forecast_page, 'Loading..'))

    # Forecast View Page Connectors
    ui.look_up_forecast_view_pb.clicked.connect(
        lambda: call_worker(lambda: lookup_item_clicked(ui), ui, ui.
                            forecast_view_page, 'Looking up..'))
    ui.forecast_view_item_id_line_edit.textChanged[str].connect(
        lambda: ui.look_up_forecast_view_pb.setEnabled(look_up_valid(ui)))
    ui.forecast_view_location_line_edit.textChanged[str].connect(
        lambda: ui.look_up_forecast_view_pb.setEnabled(look_up_valid(ui)))
    ui.back_forecast_view_pb.clicked.connect(
        lambda: call_worker(lambda: populate_forecasts(ui), ui, ui.
                            select_forecast_page, 'Loading..'))

    # Error Page Connectors
    ui.error_ok_pb.clicked.connect(lambda: return_from_error_page(ui))