Design

Published

September 18, 2024

This document is mainly to help with developing the package, so would be of more interest to admin, contributors, or other package developers.

Input and output

As much as possible, functions:

  • require zero to two arguments
  • output a vector or data frame

Naming scheme

Principles are:

  • Use snake case
  • Use verbs for actions
  • Use nouns for objects
  • Shorter over longer

Headers and their objects are named with the following scheme:

header_action_object()

RAP overall project (rap)

  • Objects: database, file, path, user, schema
  • Actions: get, delete, copy, create, move
rap_get_user()
rap_get_path_users()
rap_get_path_dirs(path)
rap_get_path_files(path)
rap_get_path_user_files(user)
rap_get_path_schema()
rap_get_path_database()

rap_copy_from(rap_path, local_path)
rap_copy_to(local_path, rap_path)

rap_move_file(path, output_dir)

rap_delete_file(path)

Researchers’ project while in RAP (proj)

  • Objects: RStudio config, Git config, dataset, name (of project folder), dependencies, rap
  • Actions: get, setup, create
proj_get_name()
proj_get_dependencies()
proj_get_git_config()
proj_get_rstudio_config()

proj_setup_rap()
proj_setup_git_config()
proj_setup_rstudio_config()

proj_create_dataset(fields, output_path)
proj_create_path_dataset(user)

Data

  • Objects: rows, columns, column names, or row group name, parquet?
  • On data: drop, keep (rows), remove, add (columns), create
drop_rows_*(data)
keep_rows_*(data)
remove_column_*(data)
add_column_*(data)
create_data_*(data)

rename_columns_to_title(data)

write_parquet(data, output_path)

Admin (admin)

  • Objects: proposals, projects and their IDs (abbreviations), paths, Google Sheets ID, site, quarto, pkgdown
  • Actions: get, create, read, build
admin_read_proposals()
admin_get_path_proposals()

admin_get_sheets_id()

admin_read_project(path)
admin_read_projects()
admin_get_project_ids()
admin_get_path_projects()
admin_create_project()

GitHub (gh)

  • Objects: users, team, repos, org, tags
  • Actions: get, create, add, remove, download
gh_get_users()
gh_get_repos()

gh_get_team()
gh_get_org()

gh_download_repo(repo)
gh_create_repo(repo)

gh_add_repo_to_team(repo)
gh_remove_repo_from_team(repo)

gh_add_user_to_team(user)
gh_add_user_to_repo(user)
gh_remove_user_from_team(user)
gh_remove_user_from_repo(user)

gh_get_tags()
gh_create_tag(version, message)

Zenodo (zen)

  • Objects: file, repo, metadata, record, token, JSON template
  • Actions: create, get, update, copy
zen_get_token()
zen_create_protocol_metadata(path)
zen_copy_template_json()
zen_create_record(path, metadata)
zen_get_record(id, token)

General or internal

  • Objects: gh, dx, cli, ukbaid
  • Actions: verify, run
run_dx(command)
run_gh(command)

verify_dx()
verify_gh()
verify_cli()
verify_ukbaid()