Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check if files exist to klaas_split_data #47

Open
jebuss opened this issue Dec 6, 2017 · 1 comment
Open

Add a check if files exist to klaas_split_data #47

jebuss opened this issue Dec 6, 2017 · 1 comment
Assignees

Comments

@jebuss
Copy link
Member

jebuss commented Dec 6, 2017

if one of the files you create with klaas_split_data, you might get the following error:

klaas_split_data build/data/gamma_precuts.hdf5 build/data/gamma \
        -f 0.25 -n train_sep \
        -f 0.5 -n train_reg \
        -f 0.25 -n test \
        -i events
INFO:root:Found a total of 692836 single-telescope events in the file
INFO:root:Writing 173209 telescope-array events to: build/data/gamma_train_sep.hdf5
Traceback (most recent call last):
  File "/home/jbuss/.conda/envs/gamma/bin/klaas_split_data", line 11, in <module>
    load_entry_point('klaas', 'console_scripts', 'klaas_split_data')()
  File "/home/jbuss/.conda/envs/gamma/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/jbuss/.conda/envs/gamma/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/jbuss/.conda/envs/gamma/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jbuss/.conda/envs/gamma/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/jbuss/software/classifier-tools/klaas/scripts/split_data.py", line 111, in main
    write_data(selected_data, path, key=key, use_hp5y=not use_pandas)
  File "/home/jbuss/software/pyfact/fact/io.py", line 34, in write_data
    to_h5py(file_path, df, key=key, **kwargs)
  File "/home/jbuss/software/pyfact/fact/io.py", line 267, in to_h5py
    append_to_h5py(f, array, key=key)
  File "/home/jbuss/software/pyfact/fact/io.py", line 428, in append_to_h5py
    raise KeyError('No such dataset {}'.format(dataset))
KeyError: 'No such dataset None'
make: *** [build/data/gamma_train_reg.hdf5] Fehler 1

I suggest, that klaas_split_data checks if files excist before and gives a warning

@jebuss
Copy link
Member Author

jebuss commented Dec 6, 2017

maybe even a prompt if files should be overwritten

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

No branches or pull requests

3 participants