Dataset Viewer issue and Assistance

#2
by rdpahalavan - opened

The dataset viewer is not working.

cc @albertvillanova @lhoestq @severo .

Hello,

I have a hard time making the dataset viewer work. I am new here and also don't know how to write the dataset loading script correctly. My loading script is:

"""CIC-IDS2017"""

import os
import csv
import pandas as pd
import pyarrow.csv
import datasets

_DESCRIPTION = ""

_HOMEPAGE = ""

_URLS = {
    "Network-Flows": "Network-Flows/CICIDS-Flow.csv",
    "Packet-Bytes": "Packet-Bytes/Packet_Bytes_File_1.csv",
    "Packet-Fields": "Packet-Fields/Packet_Fields_File_1.csv",
    "Payload-Bytes": "Payload-Bytes/Payload_Bytes_File_1.csv",
}

class NewDataset(datasets.GeneratorBasedBuilder):
    VERSION = datasets.Version("1.0.0")

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(name="Network-Flows", version=VERSION, description="Network-Flows"),
        datasets.BuilderConfig(name="Packet-Bytes", version=VERSION, description="Packet-Bytes"),
        datasets.BuilderConfig(name="Packet-Fields", version=VERSION, description="Packet-Fields"),
        datasets.BuilderConfig(name="Payload-Bytes", version=VERSION, description="Payload-Bytes"),
    ]

    DEFAULT_CONFIG_NAME = "Network-Flows"

    def _info(self):
        filepath = _URLS[self.config.name]
        csv_file = pyarrow.csv.open_csv(filepath)
        schema = csv_file.schema
        features = datasets.Features.from_arrow_schema(schema)
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(features),
            homepage=_HOMEPAGE,
        )

    def _split_generators(self, dl_manager):
        url = _URLS[self.config.name]
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "filepath": URL,
                },
            ),
        ]

    # Full function is in the file that handles data type errors
    def _generate_examples(self, filepath):
        with open(filepath, encoding="utf-8") as f:
            reader = csv.DictReader(f)
            for key, row in enumerate(reader):
                yield key, row

This is for one file in each configuration, but still, it doesn't work.

This dataset has four configurations:
"Network-Flows": 1 CSV file
"Packet-Bytes": 18 CSV files (Contains more than 1000 columns - can exclude extra columns - include last label column)
"Packet-Fields": 18 CSV files (Each CSV file can contain a different total number of columns)
"Payload-Bytes": 18 CSV files (Contains more than 1000 columns - can exclude extra columns - include last label column)

I created four directories and uploaded the CSV files. Despite working on it for three days, I couldn't get the dataset viewer to function. Any help in making things work will be much appreciated. Thanks.

rdpahalavan changed discussion status to closed
rdpahalavan changed discussion status to open

Hi ! There's a new feature coming that will make it work: you'll be able to define your configurations in a few lines of YAML instead of having to write a dataset script.

Here is a sneak peak at the documentation (wip): https://moon-ci-docs.huggingface.co/docs/datasets/pr_5331/en/repository_structure#dataset-configurations-and-subsets

cc @polinaeterna

Hi ! There's a new feature coming that will make it work: you'll be able to define your configurations in a few lines of YAML instead of having to write a dataset script.

Here is a sneak peak at the documentation (wip): https://moon-ci-docs.huggingface.co/docs/datasets/pr_5331/en/repository_structure#dataset-configurations-and-subsets

cc @polinaeterna

Fantastic! This feature will be more helpful. I am looking forward to it.

Update: I have deleted the.csv files and replaced them with .parquet files

Sign up or log in to comment