Skip to content

kaggle quota fails when API returns whole-second duration like 0s #1064

Description

@JorisViaudQuantAI

Environment

  • OS: Windows
  • Python: 3.11.9
  • kaggle: 2.2.2
  • kagglesdk: 0.1.30

Command

kaggle quota

Actual behavior

The command fails with:

not enough values to unpack (expected 2, got 1)

Expected behavior

kaggle quota should print the current accelerator quota table.

Likely cause

kagglesdk.kaggle_object.TimeDeltaSerializer._from_dict_value assumes protobuf duration strings always contain a fractional component:

(seconds, nanosRaw) = value.rstrip("s").split(".")

However, protobuf JSON duration strings may also be whole-second values such as:

0s
151s

When the quota API returns a whole-second duration, .split(".") returns one value and the command crashes.

Local patch that fixed it

I applied this local patch to TimeDeltaSerializer._from_dict_value, and kaggle quota started working:

raw_value = value.rstrip("s")
if "." not in raw_value:
    return timedelta(seconds=int(raw_value))
(seconds, nanosRaw) = raw_value.split(".")
nanos = int(nanosRaw) * TimeDeltaSerializer.SUBSECOND_SCALING_FACTORS[len(nanosRaw)]
return timedelta(seconds=int(seconds), microseconds=int(int(nanos) / 1000))

Verification after patch

Both commands work after the local patch:

kaggle quota
kaggle quota --csv

Separate note

kaggle quota --help documents -v, --csv, but -v also exists as the global kaggle --version option. On my install, kaggle quota --csv is reliable, while kaggle quota -v does not behave the same way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions