download hanging in config.py
Closed this issue · 5 comments
Maybe it's something specific to my installation, but kg download -c titanic
(or any competition) is hanging in config.py. It's stuck in the loop:
def get_config_candidates(curdir):
# derive parent dir of homedir
cnt = 0
while curdir != os.path.dirname(os.path.expanduser('~')):
config_path = os.path.join(
curdir, CONFIG_DIR_NAME, CONFIG_FILE_NAME
)
cnt += 1
print 'config_path:', config_path, cnt
if os.path.isfile(config_path):
config = ConfigParser(allow_no_value=True)
config_file = open(config_path)
config.read_file(config_file)
yield config
curdir = os.path.dirname(curdir) # derive parent dir
I added the cnt and print as a debug. It just sits there constantly increasing the cnt. My OS is Ubuntu 16.04 and I'm using Python 2. The config_path it prints is /.kaggle-cli/config
. Over and over.
I'm trying to fix it but I guess I'm a bit confused what this function is supposed to do. What do you mean by 'derive parent dir of homedir'? Something like /ubuntu if the homedir is /ubuntu/home?
The traceback is:
config_path: /.kaggle-cli/config 43027
^CTraceback (most recent call last):
File "/usr/local/bin/kg", line 11, in <module>
load_entry_point('kaggle-cli==0.8.1', 'console_scripts', 'kg')()
File "/usr/local/lib/python2.7/dist-packages/kaggle_cli/main.py", line 21, in main
return app.run(argv)
File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 279, in run
result = self.run_subcommand(remainder)
File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 400, in run_subcommand
result = cmd.run(parsed_args)
File "/usr/local/lib/python2.7/dist-packages/cliff/command.py", line 90, in run
return self.take_action(parsed_args) or 0
File "/usr/local/lib/python2.7/dist-packages/kaggle_cli/download.py", line 22, in take_action
config = get_final_config(parsed_args)
File "/usr/local/lib/python2.7/dist-packages/kaggle_cli/config.py", line 55, in get_final_config
get_working_config(get_config_candidates(os.getcwd())),
File "/usr/local/lib/python2.7/dist-packages/kaggle_cli/config.py", line 41, in get_working_config
map(lambda config: dict(config['user']), configs),
File "/usr/local/lib/python2.7/dist-packages/kaggle_cli/config.py", line 22, in get_config_candidates
print 'config_path:', config_path, cnt
KeyboardInterrupt
It turned out to be a very simple fix, but I'm wondering what to do about it:
def get_config_candidates(curdir):
# derive parent dir of homedir
while curdir != os.path.dirname(os.path.dirname(os.path.expanduser('~'))):
config_path = os.path.join(
curdir, CONFIG_DIR_NAME, CONFIG_FILE_NAME
)
if os.path.isfile(config_path):
config = ConfigParser(allow_no_value=True)
config_file = open(config_path)
config.read_file(config_file)
yield config
curdir = os.path.dirname(curdir) # derive parent dir
Basically just needed another os.path.dirname at while curdir != os.path.dirname(os.path.dirname(os.path.expanduser('~'))):
This happens for me too, even when just trying to run "kg config" (or any other command) on Windows, Python 3.5 (Anaconda). Infinite loop in the same place.
Rolling back to version 0.6.1 works as a temporary fix.
The iterative method is supposed working under user's home dir, i.e. /home/peter
.
According to your report, you seem to execute it outside the home dir, so it's broken.
I'll fix it soon.
The fix fe5db03 is on the PyPi, @nateGeorge @TimothyFitz could you help to test it?
I'm going to close this issue, if the problem still exists, feel free to reopen.