Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Serializing multiple times with capnproto, KjException: capnp/dynamic.c++:1777: failed #3805

Open
ghost opened this issue Feb 15, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 15, 2018

    from nupic.frameworks.opf.htm_prediction_model import HTMPredictionModel
    def test_mutliple_rounds_opf_serialization(self):
        for i in range(500):
            self.anomaly_model.process_sample(self.source.next())

        self.anomaly_model.save(CHECKPOINT_DIR)
        restored_model = AnomalyModel.load(CHECKPOINT_DIR)

        restored_model.save(CHECKPOINT_DIR)
        restored_model = AnomalyModel.load(CHECKPOINT_DIR)

        restored_model.save(CHECKPOINT_DIR)
        AnomalyModel.load(CHECKPOINT_DIR)

    def test_multiple_rounds_serialization(self):
        for i in range(500):
            sample = self.source.next()
            self.anomaly_model.process_sample(sample)

        proto1 = HTMPredictionModel.getSchema()
        builder = proto1.new_message()
        self.anomaly_model.htm_model.write(builder)
        data1 = builder.to_bytes_packed()

        proto2 = HTMPredictionModel.getSchema()
        reader = proto2.from_bytes_packed(data1)
        model = HTMPredictionModel.read(reader)

        proto3 = HTMPredictionModel.getSchema()
        builder = proto3.new_message()
        model.write(builder)
        data2 = builder.to_bytes_packed()
        self.assertEqual(data2, data1)

Both of these tests return the same error. It looks like it's not possible to serialize models more than once?

Edit: It seems this error doesn't show up as long as you compute samples in between serializing. I can't see why we wouldn't do that, maybe this issue doesn't matter.

KjException: capnp/dynamic.c++:1777: failed: expected reader.type == BOOL; Value type mismatch.
stack: 0x7f6162dcd0a8 0x7f6162ce04ad 0x7f6162ce215d 0x7f6162c49928 0x7f6162ce0bff 0x7f6162ce215d 0x7f6162c49928 0x7f6162cdc631 0x7f6162cdf066 0x7f6162c762ee 0x7f617ce779df 0x7f617cee158b 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee6b80 0x7f617ce5c955 0x7f617ce2a983 0x7f616103af72 0x7f616103b3bd 0x7f6160ff0d1f 0x7f61610ae224 0x7f61610c6927 0x7f617cee3b16 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee6b80 0x7f617ce5c955

HAPPY VALENTINES DAY

@ghost ghost changed the title Serializing multiple times with capnproto results in vague errors Serializing multiple times with capnproto, KjException: capnp/dynamic.c++:1777: failed Feb 15, 2018
@rhyolight
Copy link
Member

Interesting. Will keep this report around, but probably will not prioritize for an immediate fix.

@ghost
Copy link
Author

ghost commented May 30, 2018

Just bumping this issue for visualization, it is not important, today I was writing some serialization tests and got this error, took me a while to remember that you cannot serialize/deserialize/serialize without processing samples in between.

It's not an important bug, but some warning somewhere might help other people who run into this and don't just get lucky and stumble into this fact.

@rhyolight
Copy link
Member

I just released NuPIC 1.0.5 like 5 minutes ago. You might try with this new release, because we updated the CAPNP version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant