def setup_pretrained_endpoints_rdf()

in src/graph_notebook/notebooks/03-Neptune-ML/02-SPARQL/neptune_ml_sparql_utils.py [0:0]


    def setup_pretrained_endpoints_rdf(self, s3_bucket_uri: str, setup_object_classification: bool,
                                       setup_object_regression: bool, setup_link_prediction: bool):
        print('Beginning endpoint creation', end='\r')
        if setup_object_classification:
            # copy model
            self.__copy_s3(f'{s3_bucket_uri}/rdf/pretrained-models/object-classification/model.tar.gz',
                           self.PRETRAINED_MODEL['object_classification'])
            # create model
            classification_output = self.__create_model(
                'classifi', f'{s3_bucket_uri}/rdf/pretrained-models/object-classification/model.tar.gz')
        if setup_object_regression:
            # copy model
            self.__copy_s3(f'{s3_bucket_uri}/rdf/pretrained-models/object-regression/model.tar.gz',
                           self.PRETRAINED_MODEL['object_regression'])
            # create model
            regression_output = self.__create_model(
                'regressi', f'{s3_bucket_uri}/rdf/pretrained-models/object-regression/model.tar.gz')
        if setup_link_prediction:
            # copy model
            self.__copy_s3(f'{s3_bucket_uri}/rdf/pretrained-models/link-prediction/model.tar.gz',
                           self.PRETRAINED_MODEL['link_prediction'])
            # create model
            prediction_output = self.__create_model(
                'linkpred', f'{s3_bucket_uri}/rdf/pretrained-models/link-prediction/model.tar.gz')

        sleep(UPDATE_DELAY_SECONDS)
        classification_running = setup_object_classification
        regression_running = setup_object_regression
        prediction_running = setup_link_prediction
        classification_endpoint_name = ""
        regression_endpoint_name = ""
        prediction_endpoint_name = ""
        sm = boto3.client("sagemaker")

        while classification_running or regression_running or prediction_running:
            if classification_running:
                response = sm.describe_endpoint(
                    EndpointName=classification_output
                )
                if response['EndpointStatus'] in ['InService', 'Failed']:
                    if response['EndpointStatus'] == 'InService':
                        classification_endpoint_name = response
                    classification_running = False
            if regression_running:
                response = sm.describe_endpoint(
                    EndpointName=regression_output
                )
                if response['EndpointStatus'] in ['InService', 'Failed']:
                    if response['EndpointStatus'] == 'InService':
                        regression_endpoint_name = response
                    regression_running = False
            if prediction_running:
                response = sm.describe_endpoint(
                    EndpointName=prediction_output
                )
                if response['EndpointStatus'] in ['InService', 'Failed']:
                    if response['EndpointStatus'] == 'InService':
                        prediction_endpoint_name = response
                    prediction_running = False

            print(
                f'Checking Endpoint Creation Statuses at {datetime.now().strftime("%H:%M:%S")}', end='\r')
            sleep(UPDATE_DELAY_SECONDS)

        print("")
        if classification_endpoint_name:
            print(
                f"Node Classification Endpoint Name: {classification_endpoint_name['EndpointName']}")
        if regression_endpoint_name:
            print(
                f"Node Regression Endpoint Name: {regression_endpoint_name['EndpointName']}")
        if prediction_endpoint_name:
            print(
                f"Link Prediction Endpoint Name: {prediction_endpoint_name['EndpointName']}")

        print('Endpoint creation complete', end='\r')
        return {
            'object_classification_endpoint_name': classification_endpoint_name,
            'object_regression_endpoint_name': regression_endpoint_name,
            'link_prediction_endpoint_name': prediction_endpoint_name
        }