Ejemplo n.º 1
0
    def set_artifact_store(self, artifact_store_path: Text):
        """
        Updates artifact store to point to path.

        Args:
            artifact_store_path: new path to artifact store
        """
        self.artifact_store = ArtifactStore(artifact_store_path)
        self.save()
Ejemplo n.º 2
0
    def from_config(self, config_dict: Dict):
        """
        Sets metadata and artifact_store variables

        Args:
            config_dict (dict): .zenml config object in dict format.
        """
        assert METADATA_KEY in config_dict
        assert ARTIFACT_STORE_KEY in config_dict
        assert PIPELINES_DIR_KEY in config_dict

        self.artifact_store = ArtifactStore(config_dict[ARTIFACT_STORE_KEY])
        self.metadata_store = ZenMLMetadataStore.from_config(
            config=config_dict[METADATA_KEY])
        self.pipelines_dir = config_dict[PIPELINES_DIR_KEY]
Ejemplo n.º 3
0
    def from_config(cls, config: Dict):
        """
        Convert from pipeline config to ZenML Pipeline object.

        All steps are also populated and configuration set to parameters set
        in the config file.

        Args:
            config: a ZenML config in dict-form (probably loaded from YAML).
        """
        # start with artifact store
        artifact_store = ArtifactStore(config[keys.GlobalKeys.ARTIFACT_STORE])

        # metadata store
        metadata_store = ZenMLMetadataStore.from_config(
            config=config[keys.GlobalKeys.METADATA_STORE])

        # orchestration backend
        backend = OrchestratorBaseBackend.from_config(
            config[keys.GlobalKeys.BACKEND])

        # pipeline configuration
        p_config = config[keys.GlobalKeys.PIPELINE]
        kwargs = p_config[keys.PipelineKeys.ARGS]
        pipeline_name = kwargs.pop(keys.PipelineDetailKeys.NAME)
        pipeline_source = p_config[keys.PipelineKeys.SOURCE]

        # populate steps
        steps_dict: Dict = {}
        for step_key, step_config in p_config[keys.PipelineKeys.STEPS].items():
            steps_dict[step_key] = BaseStep.from_config(step_config)

        # datasource
        datasource = BaseDatasource.from_config(
            config[keys.GlobalKeys.PIPELINE])

        class_ = source_utils.load_source_path_class(pipeline_source)

        obj = class_(steps_dict=steps_dict,
                     backend=backend,
                     artifact_store=artifact_store,
                     metadata_store=metadata_store,
                     datasource=datasource,
                     pipeline_name=pipeline_name,
                     name=cls.get_name_from_pipeline_name(pipeline_name),
                     **kwargs)
        obj._immutable = True
        return obj
Ejemplo n.º 4
0
training_pipeline.add_evaluator(
    TFMAEvaluator(
        slices=[['has_diabetes']],
        metrics={'has_diabetes': ['binary_crossentropy', 'binary_accuracy']}))

# Add cortex deployer
api_config = {
    "name": CORTEX_MODEL_NAME,
    "kind": "RealtimeAPI",
    "predictor": {
        "type": "tensorflow",
        # Set signature key of the model as we are using Tensorflow Trainer
        "models": {
            "signature_key": "serving_default"
        }
    }
}
training_pipeline.add_deployment(
    CortexDeployer(
        env=CORTEX_ENV,
        api_config=api_config,
        predictor=TensorFlowPredictor,
    ))

# Define the artifact store
artifact_store = ArtifactStore(
    os.path.join(GCP_BUCKET, 'cortex/artifact_store'))

# Run the pipeline
training_pipeline.run(artifact_store=artifact_store)
Ejemplo n.º 5
0
# Add an evaluator
training_pipeline.add_evaluator(
    TFMAEvaluator(
        slices=[['has_diabetes']],
        metrics={'has_diabetes': ['binary_crossentropy', 'binary_accuracy']}))

# Define the metadata store
metadata_store = MySQLMetadataStore(
    host=MYSQL_HOST,
    port=int(MYSQL_PORT),
    database=MYSQL_DB,
    username=MYSQL_USER,
    password=MYSQL_PWD,
)

# Define the artifact store
artifact_store = ArtifactStore(
    os.path.join(GCP_BUCKET, 'gcp_gcaip_training/artifact_store'))

# Define the orchestrator backend
orchestrator_backend = OrchestratorGCPBackend(
    cloudsql_connection_name=GCP_CLOUD_SQL_INSTANCE_NAME, project=GCP_PROJECT)

# Run the pipeline
training_pipeline.run(
    backend=orchestrator_backend,
    metadata_store=metadata_store,
    artifact_store=artifact_store,
)
Ejemplo n.º 6
0
                  metrics={
                      transformed_label_name('has_diabetes'):
                      ['binary_crossentropy', 'binary_accuracy']
                  }))

# Define the metadata store
metadata_store = MySQLMetadataStore(
    host=MYSQL_HOST,
    port=int(MYSQL_PORT),
    database=MYSQL_DB,
    username=MYSQL_USER,
    password=MYSQL_PWD,
)

# Define the artifact store
artifact_store = ArtifactStore(
    os.path.join(GCP_BUCKET, 'gcp_orchestrated/artifact_store'))

# Define the orchestrator backend
orchestrator_backend = OrchestratorGCPBackend(
    cloudsql_connection_name=CONNECTION_NAME,
    project=GCP_PROJECT,
    preemptible=True,  # reduce costs by using preemptible instances
)

# Run the pipeline
training_pipeline.run(
    backend=orchestrator_backend,
    metadata_store=metadata_store,
    artifact_store=artifact_store,
)
Ejemplo n.º 7
0
training_pipeline.add_evaluator(
    TFMAEvaluator(slices=[['has_diabetes']],
                  metrics={
                      transformed_label_name('has_diabetes'):
                      ['binary_crossentropy', 'binary_accuracy']
                  }))

# Define the metadata store
metadata_store = MySQLMetadataStore(
    host=MYSQL_HOST,
    port=int(MYSQL_PORT),
    database=MYSQL_DB,
    username=MYSQL_USER,
    password=MYSQL_PWD,
)

# Define the artifact store
artifact_store = ArtifactStore(
    os.path.join(GCP_BUCKET, 'kubernetes_orcestrated/artifact_store'))

# Define the orchestrator backend
orchestrator_backend = OrchestratorKubernetesBackend(
    kubernetes_config_path=K8S_CONFIG_PATH, image_pull_policy="Always")

# Run the pipeline on a Kubernetes Cluster
training_pipeline.run(
    backend=orchestrator_backend,
    metadata_store=metadata_store,
    artifact_store=artifact_store,
)
Ejemplo n.º 8
0
                         epochs=20))

# Add an evaluator
training_pipeline.add_evaluator(
    TFMAEvaluator(
        slices=[['has_diabetes']],
        metrics={'has_diabetes': ['binary_crossentropy', 'binary_accuracy']}))

# Define the metadata store
metadata_store = MySQLMetadataStore(
    host=MYSQL_HOST,
    port=int(MYSQL_PORT),
    database=MYSQL_DB,
    username=MYSQL_USER,
    password=MYSQL_PWD,
)

# Define the artifact store
artifact_store = ArtifactStore(
    os.path.join(S3_BUCKET, 'aws_orchestrated/artifact_store'))

# Define the orchestrator backend
orchestrator_backend = OrchestratorAWSBackend(iam_role=IAM_ROLE)

# Run the pipeline
training_pipeline.run(
    backend=orchestrator_backend,
    metadata_store=metadata_store,
    artifact_store=artifact_store,
)
Ejemplo n.º 9
0
                         overwrite={
                             'has_diabetes': {
                                 'transform': [{
                                     'method': 'no_transform',
                                     'parameters': {}
                                 }]
                             }
                         }).with_backend(processing_backend))

# Add a trainer
training_pipeline.add_trainer(
    TFFeedForwardTrainer(loss='binary_crossentropy',
                         last_activation='sigmoid',
                         output_units=1,
                         metrics=['accuracy'],
                         epochs=20))

# Add an evaluator
training_pipeline.add_evaluator(
    TFMAEvaluator(slices=[['has_diabetes']],
                  metrics={
                      transformed_label_name('has_diabetes'):
                      ['binary_crossentropy', 'binary_accuracy']
                  }).with_backend(processing_backend))
# Define the artifact store
artifact_store = ArtifactStore(
    os.path.join(GCP_BUCKET, 'dataflow_processing/artifact_store'))

# Run the pipeline
training_pipeline.run(artifact_store=artifact_store)