示例#1
0
    def testLogKVComponentRun(self):
        # Tests implementation of values in iopointer
        create_component(
            name="valtest",
            description="Tests implementation of values in iopointer.",
            owner="me",
        )

        iop1 = ["this", "is", "the", "first"]
        iop2 = ["this", "is", "the", "second"]

        # Create iopointers and CR
        iop1 = IOPointer(name="iop1", value=iop1)
        iop2 = IOPointer(name="iop2", value=iop2)

        cr = ComponentRun("valtest")
        cr.set_start_timestamp()
        cr.set_end_timestamp()
        cr.add_input(iop1)
        cr.add_output(iop2)
        log_component_run(cr)
示例#2
0
def inference(model_files) -> str:
    identifier = "".join(
        random.choice(string.ascii_lowercase) for i in range(10))
    return identifier


if __name__ == "__main__":
    # Run training once
    version = "0"
    first_model_file = training(version)

    # Fake a component run from 2 months ago
    now = datetime.utcnow()
    cr = ComponentRun(
        "some_old_component",
        start_timestamp=now.replace(month=now.month - 2),
        end_timestamp=now,
    )
    second_model_file = "model_1"
    cr.add_input("1")
    cr.add_output(second_model_file)
    log_component_run(cr)

    # Run training again
    version = "2"
    third_model_file = training(version)

    # Run inference on old model file. This should be stale!
    first_identifier = inference([first_model_file, second_model_file])
    print(first_identifier)