コード例 #1
0
    def modify_node(self, node):
        """Modifies the ``ast.Call`` node to call ``TrainingInput`` instead.

        Args:
            node (ast.Call): a node that represents a *TrainingInput constructor.
        """
        if matching.matches_name(node, S3_INPUT_NAME):
            node.func.id = "TrainingInput"
        elif matching.matches_attr(node, S3_INPUT_NAME):
            node.func.attr = "TrainingInput"
            _rename_namespace(node, "session")
        return node
コード例 #2
0
def _rename_class(node):
    """Renames the RealTimePredictor base class to Predictor"""
    if matching.matches_name(node, BASE_PREDICTOR):
        node.func.id = "Predictor"
    elif matching.matches_attr(node, BASE_PREDICTOR):
        node.func.attr = "Predictor"
コード例 #3
0
def test_matches_attr():
    assert matching.matches_attr(ast_call("sagemaker.amazon.kmeans.KMeans()"),
                                 "KMeans")
    assert not matching.matches_attr(ast_call("KMeans()"), "KMeans")
    assert not matching.matches_attr(ast_call("sagemaker.mxnet.MXNet()"),
                                     "KMeans")