Skip to content
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

Refactor DO v1 API #806

Closed
Jesus89 opened this issue Jun 25, 2019 · 0 comments · Fixed by #857
Closed

Refactor DO v1 API #806

Jesus89 opened this issue Jun 25, 2019 · 0 comments · Fixed by #857
Assignees
Labels

Comments

@Jesus89
Copy link
Member

Jesus89 commented Jun 25, 2019

Move the data method from context to a new entity (an object? a function?)

In this first iteration, we can keep the DO methods boundaries and discovery in a separated class. We will add the augment method to the Dataset class:

  • cc.data_boundaries -> DataObs.boundaries
  • cc.data_discovery -> DataObs.discovery
  • dd.data -> Dataset.augment

From the doc:

Old API

con = cartoframes.auth.Context('base url', 'api key')
tracts = con.data_boundaries(
   boundary='us.census.tiger.census_tract',
   region=[-112.096642,43.429932,-111.974213,43.553539]
)
con.write(tracts, 'idaho_falls_tracts')
median_income_meta = con.data_discovery(
   'idaho_falls_tracts',
   keywords='median income',
   boundaries='us.census.tiger.census_tract'
)
idaho_falls_income = con.data(
    'idaho_falls_tracts',
    median_income_meta,
    how='geom_refs'
)
con.write(idaho_falls_income, 'idaho_falls_tracts', overwrite=True)

New API proposal

from cartoframes.client import DataObsClient
do = DataObsClient(creds)
tracts = do.boundaries(
    boundary=us.census.tiger.census_track’,
    region=[-112.096642,43.429932,-111.974213,43.553539]
)
tracts.upload(‘idaho_falls_tracts’)
median_income_meta = do.discovery(
    ‘Idaho_falls_tracts’,
    keywords='median income',
    boundaries=us.census.tiger.census_tract’
)
idaho_falls_income = do.augment(
    'idaho_falls_tracts',
    median_income_meta,
    how=geom_refs’
)
idaho_falls_income.upload('idaho_falls_tracts', if_exists=replace’)
@Jesus89 Jesus89 added this to the [1.0b2] Refactor Data API milestone Jun 25, 2019
@Jesus89 Jesus89 self-assigned this Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant