示例#1
0
    def setUp(self):
        self.mock_component_run = ComponentRun("mock_component_run")
        self.mock_component_run_dict = {
            "component_name": "mock_component_run",
            "notes": "",
            "inputs": [],
            "outputs": [],
            "git_hash": None,
            "git_tags": None,
            "code_snapshot": None,
            "start_timestamp": None,
            "end_timestamp": None,
            "dependencies": [],
            "id": None,
            "stale": [],
            "test_result": None,
            "mlflow_run_id": None,
            "mlflow_run_params": None,
            "mlflow_run_metrics": None,
        }

        self.mock_inputs = [
            IOPointer("mock_input_1"),
            IOPointer("mock_input_2"),
        ]
        self.mock_outputs = [
            IOPointer("mock_output_1"),
            IOPointer("mock_output_2"),
        ]
示例#2
0
    def testLogEmptyComponentRun(self):
        # Create component then log a run of it
        create_component("test_component", "test_description", "shreya")

        # Create a ComponentRun
        cr = ComponentRun("test_component")

        with self.assertRaises(RuntimeError):
            log_component_run(cr)
示例#3
0
    def testLogBasicComponentRun(self):
        # Create component then log a run of it
        create_component("test_component", "test_description", "shreya")

        # Create a ComponentRun
        cr = ComponentRun(component_name="test_component")
        cr.set_start_timestamp()
        cr.code_snapshot = b"def main(): return"
        cr.add_inputs(["duplicate_input", "duplicate_input"])
        cr.add_outputs(["duplicate_output", "duplicate_output"])
        cr.set_end_timestamp()

        # Log component run
        log_component_run(cr)
示例#4
0
    def setUp(self):
        self.mock_component_run = ComponentRun("mock_component_run")
        self.mock_component_run_dict = {
            "component_name": "mock_component_run",
            "inputs": [],
            "outputs": [],
            "git_hash": None,
            "code_snapshot": None,
            "start_timestamp": None,
            "end_timestamp": None,
            "dependencies": [],
            "id": None,
            "stale": [],
        }

        self.mock_inputs = [IOPointer("mock_input_1"), IOPointer("mock_input_2")]
        self.mock_outputs = [IOPointer("mock_output_1"), IOPointer("mock_output_2")]
示例#5
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)
示例#6
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)