<jupyter_start><jupyter_text>This notebook sets some prereqs if running in dockerized environment such as https://mybinder.org*** Important: This notebook will auto close if unused for 10 minutes. If that occurs reload from the initial url. ***  Feature key must be set (make sure this is not shared or placed in a public place) and aerospike database server started.<jupyter_code>import os
import subprocess
import pprint
import time

features = """
COPY FEATURE FILE CONTENTS HERE
"""

if features.strip() == "" or features.strip() == "COPY FEATURE FILE CONTENTS HERE":
    raise Exception ("valid features must be set above")

features_file = open("/etc/aerospike/features.conf", "w")
n = features_file.write(features)
features_file.close()


os.system("/entrypoint.sh")

pp = pprint.PrettyPrinter(indent=4)

pp.pprint(subprocess.run(["asd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.splitlines())

pp.pprint(subprocess.run(["whoami"], stdout=subprocess.PIPE).stdout.splitlines())

time.sleep(10) # may not be long enough for server to finish starting. Check the logs in the next step.<jupyter_output><empty_output><jupyter_text>Wait until aerospike has started correctly by checking the logsNote: If you need to check the aerospike logs at any time, rerun this.<jupyter_code>pp.pprint(subprocess.run(["cat", "/tmp/aerolog"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.splitlines())<jupyter_output><empty_output><jupyter_text>Execute basic python example to ensure database is connected<jupyter_code># import the module
from __future__ import print_function
import aerospike

# Configure the client
config = {
  'hosts': [ ('127.0.0.1', 3000) ]
}

# Create a client and connect it to the cluster
try:
  client = aerospike.client(config).connect()
except:
  import sys
  print("failed to connect to the cluster with", config['hosts'])
  sys.exit(1)

# Records are addressable via a tuple of (namespace, set, key)
key = ('test', 'demo', 'foo')

try:
  # Write a record
  client.put(key, {
    'name': '<NAME>',
    'age': 32
  })
except Exception as e:
  import sys
  print("error: {0}".format(e), file=sys.stderr)

# Read a record
(key, metadata, record) = client.get(key)
print(record)

# Close the connection to the Aerospike cluster
client.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1185121107266436, 'fraction_numerical': 0.008217993079584774, 'mean_word_length': 5.354395604395604, 'pattern_counts': {'":': 1, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '76337', 'license': 'Apache-2.0', 'n_tokens_mistral': 758, 'n_tokens_neox': 717, 'n_words': 237, 'path': 'aerospike/BINDER_SETUP_RUN_FIRST.ipynb', 'repo_name': 'arrowplum/interactive-notebooks', 'size': '2314'}