Exemplo n.º 1
0
    def test_cartocontext_credentials(self):
        """context.CartoContext.__init__ Credentials argument"""
        creds = cartoframes.Credentials(username=self.username,
                                        key=self.apikey)
        cc = cartoframes.CartoContext(creds=creds)
        self.assertIsInstance(cc, cartoframes.CartoContext)
        self.assertEqual(cc.creds.username(), self.username)
        self.assertEqual(cc.creds.key(), self.apikey)

        # CartoContext pulls from saved credentials
        saved_creds = cartoframes.Credentials(username=self.username,
                                              key=self.apikey)
        saved_creds.save()
        cc_saved = cartoframes.CartoContext()
        self.assertEqual(cc_saved.creds.key(), self.apikey)
Exemplo n.º 2
0
import cartoframes
import pandas as pd
import geopandas as gpd
from google.cloud import bigquery
get_ipython().magic('load_ext google.cloud.bigquery')

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/.google.json"
os.environ["GOOGLE_CLOUD_PROJECT"] = "aqueduct30"
client = bigquery.Client(project=BQ_PROJECT_ID)

# In[4]:

F = open("/.carto_builder", "r")
carto_api_key = F.read().splitlines()[0]
F.close()
creds = cartoframes.Credentials(key=carto_api_key, username='******')
cc = cartoframes.CartoContext(creds=creds)

# In[5]:

get_ipython().system('rm -r {ec2_output_path}')
get_ipython().system('mkdir -p {ec2_output_path}')

# In[6]:

sql = """
SELECT
  delta_id,
  pfafid_30spfaf06,
  temporal_resolution,
  year,
Exemplo n.º 3
0
def getCartoContext(username, apikey):
    creds = cf.Credentials(username=username, key=apikey)
    cc = cf.CartoContext(creds=creds)
    return cc