pyDataverse icon indicating copy to clipboard operation
pyDataverse copied to clipboard

Re-factor API module

Open skasberger opened this issue 4 years ago • 1 comments

Re-factor API module.

Requirements

  • Reduce API interfaces to Native and Sword
  • Make methods and variables private and access them through getters/setters (@property, @func_name.setter)
  • Use session for requests
  • Store Dataverse installation version when instantiating API
  • Check if Dataverse installation already has endpoint before accessing
  • Make function call more intuitive from the users perspective, not from the API endpoints / programmers one.
  • Align to user stories

ACTIONS

0. Pre-Requisites

  • [ ] Return specific data types #132

1. Research

  • [ ] Check out notes_api.md
  • [ ] Review existing module
  • [ ] Check sessions usage in Wikipedia() package: set headers, close, etc.
  • [ ] Identify most-common use-cases and their API requests needed?
    • [ ] Identify the helpful response objects
  • [ ] Check usage of abstract base class (ABC)
  • [ ] Automatically check file integrity after download with hash comparison.
  • [ ] List up all endpoints, cluster to logical groups. Then use result of identified user stories to improve naming and functionality.

User stories

Function naming and structure

  • Direct and easy to understand access to most common functionalities

  • Dataverse

    • get_dataverse_id(alias): returns the dataverse version string/int
    • get_children(alias/id)
  • Dataset

    • get_dataset_version(PID): returns directly the version string
    • get_children(pid/id)
  • Datafile

    • get_datafile_name(datafile_id): returns the datafile name string
    • get_dataframe(datafile_id): returns the datafile as Pandas dataframe

Architecture

class NativeApi():
  .__created_at
  .__api_token
  .__dataverse_version: beim ersten Aufruf runterladen und speichern
  .__dataverse_build: beim ersten Aufruf runterladen und speichern
  .api_token # @property
  .dataverse_version # @property
  .dataverse_build # @property

  def __init__(self):
    pass

class SwordApi():
  .__created_at
  .__api_token
  .__dataverse_version: beim ersten Aufruf runterladen und speichern
  .__dataverse_build: beim ersten Aufruf runterladen und speichern
  .api_token # @property
  .dataverse_version # @property
  .dataverse_build # @property

  def __init__(self):
    pass

2. Plan

  • [ ] Define requirements
  • [ ] Prioritize API functionalities by factors such as:
    • [ ] not used by AUSSDA
    • [ ] often used by users
    • [ ] critical if not working: see risk assessment

3. Implement

  • [ ] Write tests
  • [ ] Write/Update code
  • [ ] Write/Update Docs
  • [ ] Write/Update Docstrings
  • [ ] Run pytest
  • [ ] Run tox
  • [ ] Run pylint
  • [ ] Run mypy

4. Follow Ups

  • [ ] Review
    • [ ] Code
    • [ ] Tests
    • [ ] Docs

Check for architecture update of the API module.

skasberger avatar Jan 29 '21 00:01 skasberger

As discussed during the 2024-02-14 meeting of the pyDataverse working group, we are closing old milestones in favor of a new project board at https://github.com/orgs/gdcc/projects/1 and removing issues (like this one) from those old milestones. Please feel free to join the working group! You can find us at https://py.gdcc.io and https://dataverse.zulipchat.com/#narrow/stream/377090-python

pdurbin avatar Feb 14 '24 20:02 pdurbin