in src/edge/install.py [0:0]
def download_config(bucket_name):
# Check if agent is installed and configured already
if not os.path.isdir('agent'):
logger.info('No SM Edge Agent directory found. Proceeding with download of configuration package...')
# Get the configuration package with certificates and config files
with io.BytesIO() as file:
s3_client.download_fileobj(bucket_name, agent_config_package_prefix, file)
file.seek(0)
# Extract the files
tar = tarfile.open(fileobj=file)
tar.extractall('.')
tar.close()
# Replace the variables in the config file to make paths absolute
logger.info('Replacing path names in Edge Agent configuration file...')
replace_pathnames_in_config('./agent/conf/config_edge_device.json')
# Download and install SageMaker Edge Manager
agent_pkg_key = 'Releases/%s/%s.tgz' % (agent_version, agent_version)
# get the agent package
logger.info('Downloading and installing SageMaker Edge Agent binaries version \"%s\"...' % agent_version)
with io.BytesIO() as file:
s3_client.download_fileobj(agent_pkg_bucket, agent_pkg_key, file)
file.seek(0)
# Extract the files
tar = tarfile.open(fileobj=file)
tar.extractall('agent')
tar.close()
# Adjust the permissions
os.chmod('agent/bin/sagemaker_edge_agent_binary', stat.S_IXUSR|stat.S_IWUSR|stat.S_IXGRP|stat.S_IWGRP)
# Finally, create SM Edge Agent client stubs, using protobuffer compiler
logger.info('Creating protobuf agent stubs...')
os.system('mkdir -p app/')
os.system('python3 -m grpc_tools.protoc --proto_path=agent/docs/api --python_out=app/ --grpc_python_out=app/ agent/docs/api/agent.proto')