<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Setup
Simple function to generate random names (feel free to ignore this cell)
Step1:  Using Provenance in Adama
The following disables the warnings from the requests library about SSL certificates.  Do not do this in production.
Step2:  Connect the adama Python object to your API server of choice.  The official one is https
Step3:  Create a random namespace
Step4:  Add the service prov, already included in this notebook
Step5:  If you are interested in checking out the metadata file of this service, evaluate the next cell
Step6:  Do a simple search and save the result
Step7:  result can be treated as a standard Python list (it is actually a subclass of list).  An additional method .prov returns the provenance of the response.  It is equivalent to inspecting the headers of the HTTP response and following the link to the provenance object.
We can ask the provenance of the result in several formats with the following.  By default, the format is a serialized JSON object representing the PROV object
Step8:  The format prov returns the PROV object as a native Python object, that can be manipulated according to the prov library (already included in this notebook/container)
Step9:  If this is being evaluated in an IPython notebook, requesting the png format should display the image of the provenance graph (double-click on the image to see at full resolution).  The image can also be saved to a file by passing an extra argument
<ASSISTANT_TASK:>
Python Code:
import requests
import string
import random
lorem = requests.get('http://loripsum.net/api/plaintext').text
WORDS = [word.lower() 
         for word in filter(lambda c: c not in string.punctuation, lorem).split()]
def random_words(n=2):
    return '_'.join(random.choice(WORDS) for i in range(n))
Explanation: Setup
Simple function to generate random names (feel free to ignore this cell):
End of explanation
import requests
requests.packages.urllib3.disable_warnings()
Explanation: Using Provenance in Adama
The following disables the warnings from the requests library about SSL certificates.  Do not do this in production.
End of explanation
import adamalib
reload(adamalib.adamalib)
API = 'https://adama-dev.cloudapp.net/community/v0.3'
TOKEN = 'mytoken'
adama = adamalib.Adama(API, token=TOKEN, verify=False)
Explanation: Connect the adama Python object to your API server of choice.  The official one is https://api.araport.org/community/v0.3.  The parameter verify indicates whether to check SSL certificates.
End of explanation
namespace = adama.namespaces.add(name=random_words())
namespace
Explanation: Create a random namespace:
End of explanation
import provn.main
service = namespace.services.add(provn.main)
service
Explanation: Add the service prov, already included in this notebook:
End of explanation
!cat provn/metadata.yml
Explanation: If you are interested in checking out the metadata file of this service, evaluate the next cell:
End of explanation
result = service.search()
result
Explanation: Do a simple search and save the result:
End of explanation
result.prov()
Explanation: result can be treated as a standard Python list (it is actually a subclass of list).  An additional method .prov returns the provenance of the response.  It is equivalent to inspecting the headers of the HTTP response and following the link to the provenance object.
We can ask the provenance of the result in several formats with the following.  By default, the format is a serialized JSON object representing the PROV object:
End of explanation
result.prov(format='prov')
Explanation: The format prov returns the PROV object as a native Python object, that can be manipulated according to the prov library (already included in this notebook/container):
End of explanation
result.prov(format='png')
Explanation: If this is being evaluated in an IPython notebook, requesting the png format should display the image of the provenance graph (double-click on the image to see at full resolution).  The image can also be saved to a file by passing an extra argument: filename="image.png".
End of explanation
<END_TASK>