VowpalWabbit / coba

Contextual bandit benchmarking
https://coba-docs.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
48 stars 19 forks source link

JSON encoding support for rewards + some misc #42

Closed jonastim closed 1 year ago

jonastim commented 1 year ago

Added JSON serialization support for Reward subclasses for this issue:

2023-07-18 14:18:16 -- pid-4977   -- Unexpected exception:

  File "/mnt/user-home/git/coba/coba/experiments/core.py", line 168, in run
    Pipes.join(workitems, chunker, process, preamble, encode, sink).run()
  File "/mnt/user-home/git/coba/coba/pipes/primitives.py", line 181, in run
    sink.write(item)
  File "/mnt/user-home/git/coba/coba/pipes/sinks.py", line 71, in write
    batch = self._get_batch(lines)
  File "/mnt/user-home/git/coba/coba/pipes/sinks.py", line 79, in _get_batch
    if self._batch: batch = list(batch)
  File "/mnt/user-home/git/coba/coba/experiments/results.py", line 454, in filter
    yield encoder.filter(["I", item[1], { "_packed": rows_T }])
  File "/mnt/user-home/git/coba/coba/pipes/filters.py", line 228, in filter
    return self._encoder.encode(self._min(copy.deepcopy([item]))[0] if self._minify else item).replace('"|',"").replace('|"',"")
  File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '

  TypeError: Object of type IPSReward is not JSON serializable

and

2023-07-18 15:28:01 -- pid-5483   -- Unexpected exception:

  File "/mnt/user-home/git/coba/coba/experiments/core.py", line 168, in run
    Pipes.join(workitems, chunker, process, preamble, encode, sink).run()
  File "/mnt/user-home/git/coba/coba/pipes/primitives.py", line 181, in run
    sink.write(item)
  File "/mnt/user-home/git/coba/coba/pipes/sinks.py", line 71, in write
    batch = self._get_batch(lines)
  File "/mnt/user-home/git/coba/coba/pipes/sinks.py", line 79, in _get_batch
    if self._batch: batch = list(batch)
  File "/mnt/user-home/git/coba/coba/experiments/results.py", line 454, in filter
    yield encoder.filter(["I", item[1], { "_packed": rows_T }])
  File "/mnt/user-home/git/coba/coba/pipes/filters.py", line 228, in filter
    return self._encoder.encode(self._min(copy.deepcopy([item]))[0] if self._minify else item).replace('"|',"").replace('|"',"")
  File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '

  TypeError: Object of type MappingReward is not JSON serializable
codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (e70b71a) 99.90% compared to head (f7a703c) 99.90%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #42 +/- ## ======================================= Coverage 99.90% 99.90% ======================================= Files 56 56 Lines 7061 7073 +12 ======================================= + Hits 7054 7066 +12 Misses 7 7 ``` | Flag | Coverage Δ | | |---|---|---| | | `99.90% <100.00%> (+<0.01%)` | :arrow_up: | | ubuntu-latest | `99.90% <100.00%> (+<0.01%)` | :arrow_up: | | unittest | `99.90% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VowpalWabbit#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/VowpalWabbit/coba/pull/42?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VowpalWabbit) | Coverage Δ | | |---|---|---| | [coba/encodings.py](https://app.codecov.io/gh/VowpalWabbit/coba/pull/42?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VowpalWabbit#diff-Y29iYS9lbmNvZGluZ3MucHk=) | `100.00% <100.00%> (ø)` | | | [coba/evaluators/online.py](https://app.codecov.io/gh/VowpalWabbit/coba/pull/42?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VowpalWabbit#diff-Y29iYS9ldmFsdWF0b3JzL29ubGluZS5weQ==) | `100.00% <100.00%> (ø)` | | | [coba/primitives/rewards.py](https://app.codecov.io/gh/VowpalWabbit/coba/pull/42?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VowpalWabbit#diff-Y29iYS9wcmltaXRpdmVzL3Jld2FyZHMucHk=) | `100.00% <100.00%> (ø)` | | ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/VowpalWabbit/coba/pull/42/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VowpalWabbit)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.