Skip to content

<type 'list'>. Valid formats: float, int, str any object that implements __iter__ or classification_pb2.ClassificationRequest #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Feb 19, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 19, 2019

Please fill out the form below.

System Information

  • Framework (e.g. TensorFlow) / Algorithm (e.g. KMeans): TensorFlow
  • Framework Version: 1.11
  • Python Version: 2.7
  • CPU or GPU: CPU
  • Python SDK Version: 1.18.3
  • Are you using a custom image: No

Describe the problem

Getting the following error on inference: <type 'list'>. Valid formats: float, int, str any object that implements iter or classification_pb2.ClassificationRequest

Seems to come from here: https://github.com/aws/sagemaker-tensorflow-container/blob/ba46b9262da8b22e3242a4d35220679e6b9043c2/src/tf_container/proxy_client.py#L262

Saved Model Output

The given SavedModel SignatureDef contains the following input(s):
  inputs['inputs'] tensor_info:
      dtype: DT_STRING
      shape: (-1)
      name: input_example_tensor:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['classes'] tensor_info:
      dtype: DT_STRING
      shape: (-1, 20)
      name: dnn/head/Tile:0
  outputs['scores'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 20)
      name: dnn/head/predictions/probabilities:0
Method name is: tensorflow/serving/classify

Serving Request

model_spec {
  name: "generic_model"
  signature_name: "serve"
}
inputs {
  key: "inputs"
  value {
    dtype: DT_STRING
    tensor_shape {
      dim {
        size: 1
      }
    }
    string_val: "\n\230\361\004\n\224\361\004\n\006input\022\210\361\004\022\204\361\004\n

Code

INPUT_KEY = 'text'
OUTPUT_KEY = 'response'
ERROR_STRING = 'Requested unsupported ContentType, content type: '

def input_fn(serialized_input_data, content_type=JSON_CONTENT_TYPE):
    if content_type == JSON_CONTENT_TYPE:
        input_data = json.loads(serialized_input_data)
        input_features = transform(preprocess(input_data[INPUT_KEY]))
        return build_request("generic_model", input_features.tolist()) #input_features is a list of floats

    raise Exception(ERROR_STRING + content_type)

def build_request(name, input_ids, signature_name=DEFAULT_SERVING_SIGNATURE_DEF_KEY):
    examples = [make_example(input_ids).SerializeToString()]

    request = predict_pb2.PredictRequest()
    request.model_spec.name = name
    request.model_spec.signature_name = signature_name
    request.inputs["inputs"].CopyFrom(
        tf.contrib.util.make_tensor_proto(
            examples))
    return request

def make_example(input_ids, feature_name="input"):
    features = {
        feature_name:
            tf.train.Feature(float_list=tf.train.FloatList(value=input_ids))
    }
    return tf.train.Example(features=tf.train.Features(feature=features))

def transform(msg):
    msg = [preprocess(msg)]
    msg = TFIDF_VECTORIZER.transform(msg)
    return KBEST_SELECTOR.transform(msg.toarray()).flatten()

def preprocess(line):
    return re.sub("[^a-z0-9'.]+", " ", line.lower()).strip()
@ghost
Copy link
Author

ghost commented Feb 19, 2019

Whoops found my mistake. I adapted this code from another model I had and forgot to change the build_request function to create a classification request.

Working build_request function:

def build_request(name, input_ids, signature_name=DEFAULT_SERVING_SIGNATURE_DEF_KEY):
    examples = [make_example(input_ids)]
    request = classification_pb2.ClassificationRequest()
    request.model_spec.name = name
    request.model_spec.signature_name = signature_name
    request.input.example_list.examples.extend(examples)
    return request

@ghost ghost closed this as completed Feb 19, 2019
mizanfiu pushed a commit to mizanfiu/sagemaker-python-sdk that referenced this issue Dec 13, 2022
mizanfiu pushed a commit to mizanfiu/sagemaker-python-sdk that referenced this issue Dec 13, 2022
claytonparnell pushed a commit that referenced this issue Dec 15, 2022
* Add list_feature_groups API (#647)

* feat: Feature/get record api (#650)

Co-authored-by: Eric Zou <[email protected]>

* Add delete_record API (#664)

* feat: Add DatasetBuilder class (#667)

Co-authored-by: Eric Zou <[email protected]>

* feat: Add to_csv method in DatasetBuilder (#699)

* feat: Add pandas.Dataframe as base case (#708)

* feat: Add with_feature_group method in DatasetBuilder (#726)

* feat: Handle merge and timestamp filters (#727)

* feat: Add to_dataframe method in DatasetBuilder (#729)

* Address TODOs (#731)

* Unit test for DatasetBuilder (#734)

* fix: Fix list_feature_groups max_results (#744)

* Add integration tests for create_dataset (#743)

* feature: Aggregate commits

* fix: as_of, event_range, join, default behavior and duplicates… (#764)

* Bug fixed - as_of, event_range, join, default behavior and duplicates and tests

Bugs:
1. as_of was not working properly on deleted events
2. Same event_time_range
3. Join was not working when including feature names
4. Default sql was returning only most recent, whereas it should all excluding duplicates
5. Include duplicates was not return all non-deleted data
6. instanceof(dataframe) case was also applied to non-df cases while join
7. Include column was returning unnecessary columns.

* Fix on pylint error

* Fix on include_duplicated_records for panda data frames

* Fix format issue for black

* Bug fixed related to line break

* Bug fix related to dataframe and inclde_deleted_record and include_duplicated_record

* Addressed comments and code refactored

* changed to_csv to to_csv_file and added error messages for query limit and recent record limit

* Revert a change which was not intended

* Resolved the leak of feature group deletion in integration test

* Added doc update for dataset builder

* Fix the issue in doc

Co-authored-by: Yiming Zou <[email protected]>
Co-authored-by: Brandon Chatham <[email protected]>
Co-authored-by: Eric Zou <[email protected]>
Co-authored-by: jiapinw <[email protected]>
claytonparnell pushed a commit to claytonparnell/sagemaker-python-sdk that referenced this issue Dec 16, 2022
* Add list_feature_groups API (aws#647)

* feat: Feature/get record api (aws#650)

Co-authored-by: Eric Zou <[email protected]>

* Add delete_record API (aws#664)

* feat: Add DatasetBuilder class (aws#667)

Co-authored-by: Eric Zou <[email protected]>

* feat: Add to_csv method in DatasetBuilder (aws#699)

* feat: Add pandas.Dataframe as base case (aws#708)

* feat: Add with_feature_group method in DatasetBuilder (aws#726)

* feat: Handle merge and timestamp filters (aws#727)

* feat: Add to_dataframe method in DatasetBuilder (aws#729)

* Address TODOs (aws#731)

* Unit test for DatasetBuilder (aws#734)

* fix: Fix list_feature_groups max_results (aws#744)

* Add integration tests for create_dataset (aws#743)

* feature: Aggregate commits

* fix: as_of, event_range, join, default behavior and duplicates… (aws#764)

* Bug fixed - as_of, event_range, join, default behavior and duplicates and tests

Bugs:
1. as_of was not working properly on deleted events
2. Same event_time_range
3. Join was not working when including feature names
4. Default sql was returning only most recent, whereas it should all excluding duplicates
5. Include duplicates was not return all non-deleted data
6. instanceof(dataframe) case was also applied to non-df cases while join
7. Include column was returning unnecessary columns.

* Fix on pylint error

* Fix on include_duplicated_records for panda data frames

* Fix format issue for black

* Bug fixed related to line break

* Bug fix related to dataframe and inclde_deleted_record and include_duplicated_record

* Addressed comments and code refactored

* changed to_csv to to_csv_file and added error messages for query limit and recent record limit

* Revert a change which was not intended

* Resolved the leak of feature group deletion in integration test

* Added doc update for dataset builder

* Fix the issue in doc

Co-authored-by: Yiming Zou <[email protected]>
Co-authored-by: Brandon Chatham <[email protected]>
Co-authored-by: Eric Zou <[email protected]>
Co-authored-by: jiapinw <[email protected]>
mufaddal-rohawala pushed a commit to mufaddal-rohawala/sagemaker-python-sdk that referenced this issue Dec 19, 2022
* Add list_feature_groups API (aws#647)

* feat: Feature/get record api (aws#650)

Co-authored-by: Eric Zou <[email protected]>

* Add delete_record API (aws#664)

* feat: Add DatasetBuilder class (aws#667)

Co-authored-by: Eric Zou <[email protected]>

* feat: Add to_csv method in DatasetBuilder (aws#699)

* feat: Add pandas.Dataframe as base case (aws#708)

* feat: Add with_feature_group method in DatasetBuilder (aws#726)

* feat: Handle merge and timestamp filters (aws#727)

* feat: Add to_dataframe method in DatasetBuilder (aws#729)

* Address TODOs (aws#731)

* Unit test for DatasetBuilder (aws#734)

* fix: Fix list_feature_groups max_results (aws#744)

* Add integration tests for create_dataset (aws#743)

* feature: Aggregate commits

* fix: as_of, event_range, join, default behavior and duplicates… (aws#764)

* Bug fixed - as_of, event_range, join, default behavior and duplicates and tests

Bugs:
1. as_of was not working properly on deleted events
2. Same event_time_range
3. Join was not working when including feature names
4. Default sql was returning only most recent, whereas it should all excluding duplicates
5. Include duplicates was not return all non-deleted data
6. instanceof(dataframe) case was also applied to non-df cases while join
7. Include column was returning unnecessary columns.

* Fix on pylint error

* Fix on include_duplicated_records for panda data frames

* Fix format issue for black

* Bug fixed related to line break

* Bug fix related to dataframe and inclde_deleted_record and include_duplicated_record

* Addressed comments and code refactored

* changed to_csv to to_csv_file and added error messages for query limit and recent record limit

* Revert a change which was not intended

* Resolved the leak of feature group deletion in integration test

* Added doc update for dataset builder

* Fix the issue in doc

Co-authored-by: Yiming Zou <[email protected]>
Co-authored-by: Brandon Chatham <[email protected]>
Co-authored-by: Eric Zou <[email protected]>
Co-authored-by: jiapinw <[email protected]>
mufaddal-rohawala pushed a commit that referenced this issue Dec 20, 2022
* Add list_feature_groups API (#647)

* feat: Feature/get record api (#650)

Co-authored-by: Eric Zou <[email protected]>

* Add delete_record API (#664)

* feat: Add DatasetBuilder class (#667)

Co-authored-by: Eric Zou <[email protected]>

* feat: Add to_csv method in DatasetBuilder (#699)

* feat: Add pandas.Dataframe as base case (#708)

* feat: Add with_feature_group method in DatasetBuilder (#726)

* feat: Handle merge and timestamp filters (#727)

* feat: Add to_dataframe method in DatasetBuilder (#729)

* Address TODOs (#731)

* Unit test for DatasetBuilder (#734)

* fix: Fix list_feature_groups max_results (#744)

* Add integration tests for create_dataset (#743)

* feature: Aggregate commits

* fix: as_of, event_range, join, default behavior and duplicates… (#764)

* Bug fixed - as_of, event_range, join, default behavior and duplicates and tests

Bugs:
1. as_of was not working properly on deleted events
2. Same event_time_range
3. Join was not working when including feature names
4. Default sql was returning only most recent, whereas it should all excluding duplicates
5. Include duplicates was not return all non-deleted data
6. instanceof(dataframe) case was also applied to non-df cases while join
7. Include column was returning unnecessary columns.

* Fix on pylint error

* Fix on include_duplicated_records for panda data frames

* Fix format issue for black

* Bug fixed related to line break

* Bug fix related to dataframe and inclde_deleted_record and include_duplicated_record

* Addressed comments and code refactored

* changed to_csv to to_csv_file and added error messages for query limit and recent record limit

* Revert a change which was not intended

* Resolved the leak of feature group deletion in integration test

* Added doc update for dataset builder

* Fix the issue in doc

Co-authored-by: Yiming Zou <[email protected]>
Co-authored-by: Brandon Chatham <[email protected]>
Co-authored-by: Eric Zou <[email protected]>
Co-authored-by: jiapinw <[email protected]>
JoseJuan98 pushed a commit to JoseJuan98/sagemaker-python-sdk that referenced this issue Mar 4, 2023
* Add list_feature_groups API (aws#647)

* feat: Feature/get record api (aws#650)

Co-authored-by: Eric Zou <[email protected]>

* Add delete_record API (aws#664)

* feat: Add DatasetBuilder class (aws#667)

Co-authored-by: Eric Zou <[email protected]>

* feat: Add to_csv method in DatasetBuilder (aws#699)

* feat: Add pandas.Dataframe as base case (aws#708)

* feat: Add with_feature_group method in DatasetBuilder (aws#726)

* feat: Handle merge and timestamp filters (aws#727)

* feat: Add to_dataframe method in DatasetBuilder (aws#729)

* Address TODOs (aws#731)

* Unit test for DatasetBuilder (aws#734)

* fix: Fix list_feature_groups max_results (aws#744)

* Add integration tests for create_dataset (aws#743)

* feature: Aggregate commits

* fix: as_of, event_range, join, default behavior and duplicates… (aws#764)

* Bug fixed - as_of, event_range, join, default behavior and duplicates and tests

Bugs:
1. as_of was not working properly on deleted events
2. Same event_time_range
3. Join was not working when including feature names
4. Default sql was returning only most recent, whereas it should all excluding duplicates
5. Include duplicates was not return all non-deleted data
6. instanceof(dataframe) case was also applied to non-df cases while join
7. Include column was returning unnecessary columns.

* Fix on pylint error

* Fix on include_duplicated_records for panda data frames

* Fix format issue for black

* Bug fixed related to line break

* Bug fix related to dataframe and inclde_deleted_record and include_duplicated_record

* Addressed comments and code refactored

* changed to_csv to to_csv_file and added error messages for query limit and recent record limit

* Revert a change which was not intended

* Resolved the leak of feature group deletion in integration test

* Added doc update for dataset builder

* Fix the issue in doc

Co-authored-by: Yiming Zou <[email protected]>
Co-authored-by: Brandon Chatham <[email protected]>
Co-authored-by: Eric Zou <[email protected]>
Co-authored-by: jiapinw <[email protected]>
JoseJuan98 pushed a commit to JoseJuan98/sagemaker-python-sdk that referenced this issue Mar 4, 2023
* Add list_feature_groups API (aws#647)

* feat: Feature/get record api (aws#650)

Co-authored-by: Eric Zou <[email protected]>

* Add delete_record API (aws#664)

* feat: Add DatasetBuilder class (aws#667)

Co-authored-by: Eric Zou <[email protected]>

* feat: Add to_csv method in DatasetBuilder (aws#699)

* feat: Add pandas.Dataframe as base case (aws#708)

* feat: Add with_feature_group method in DatasetBuilder (aws#726)

* feat: Handle merge and timestamp filters (aws#727)

* feat: Add to_dataframe method in DatasetBuilder (aws#729)

* Address TODOs (aws#731)

* Unit test for DatasetBuilder (aws#734)

* fix: Fix list_feature_groups max_results (aws#744)

* Add integration tests for create_dataset (aws#743)

* feature: Aggregate commits

* fix: as_of, event_range, join, default behavior and duplicates… (aws#764)

* Bug fixed - as_of, event_range, join, default behavior and duplicates and tests

Bugs:
1. as_of was not working properly on deleted events
2. Same event_time_range
3. Join was not working when including feature names
4. Default sql was returning only most recent, whereas it should all excluding duplicates
5. Include duplicates was not return all non-deleted data
6. instanceof(dataframe) case was also applied to non-df cases while join
7. Include column was returning unnecessary columns.

* Fix on pylint error

* Fix on include_duplicated_records for panda data frames

* Fix format issue for black

* Bug fixed related to line break

* Bug fix related to dataframe and inclde_deleted_record and include_duplicated_record

* Addressed comments and code refactored

* changed to_csv to to_csv_file and added error messages for query limit and recent record limit

* Revert a change which was not intended

* Resolved the leak of feature group deletion in integration test

* Added doc update for dataset builder

* Fix the issue in doc

Co-authored-by: Yiming Zou <[email protected]>
Co-authored-by: Brandon Chatham <[email protected]>
Co-authored-by: Eric Zou <[email protected]>
Co-authored-by: jiapinw <[email protected]>
nmadan pushed a commit to nmadan/sagemaker-python-sdk that referenced this issue Apr 18, 2023
* Add list_feature_groups API (aws#647)

* feat: Feature/get record api (aws#650)

Co-authored-by: Eric Zou <[email protected]>

* Add delete_record API (aws#664)

* feat: Add DatasetBuilder class (aws#667)

Co-authored-by: Eric Zou <[email protected]>

* feat: Add to_csv method in DatasetBuilder (aws#699)

* feat: Add pandas.Dataframe as base case (aws#708)

* feat: Add with_feature_group method in DatasetBuilder (aws#726)

* feat: Handle merge and timestamp filters (aws#727)

* feat: Add to_dataframe method in DatasetBuilder (aws#729)

* Address TODOs (aws#731)

* Unit test for DatasetBuilder (aws#734)

* fix: Fix list_feature_groups max_results (aws#744)

* Add integration tests for create_dataset (aws#743)

* feature: Aggregate commits

* fix: as_of, event_range, join, default behavior and duplicates… (aws#764)

* Bug fixed - as_of, event_range, join, default behavior and duplicates and tests

Bugs:
1. as_of was not working properly on deleted events
2. Same event_time_range
3. Join was not working when including feature names
4. Default sql was returning only most recent, whereas it should all excluding duplicates
5. Include duplicates was not return all non-deleted data
6. instanceof(dataframe) case was also applied to non-df cases while join
7. Include column was returning unnecessary columns.

* Fix on pylint error

* Fix on include_duplicated_records for panda data frames

* Fix format issue for black

* Bug fixed related to line break

* Bug fix related to dataframe and inclde_deleted_record and include_duplicated_record

* Addressed comments and code refactored

* changed to_csv to to_csv_file and added error messages for query limit and recent record limit

* Revert a change which was not intended

* Resolved the leak of feature group deletion in integration test

* Added doc update for dataset builder

* Fix the issue in doc

Co-authored-by: Yiming Zou <[email protected]>
Co-authored-by: Brandon Chatham <[email protected]>
Co-authored-by: Eric Zou <[email protected]>
Co-authored-by: jiapinw <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants