Add bulk_add_from_file(filepath, strict=False) as file-based user import successor to deprecated create_from_file

Open
#1,836 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python

Research direction

Start by reading users.bulk_add, the deprecated create_from_file, and UserItem.CSVImport.validate_file_for_import to understand the existing import flow and POST /users/import integration. Confirm the behavior for strict and non-strict validation, including the JobItem and SkippedLine results, and consider how tabcmd issue #1809 would use the method.

Written by the indexing model from the issue text.

Description

enhancement

Summary

Add users.bulk_add_from_file(filepath, strict=False) -> tuple[JobItem, list[SkippedLine]] as the modern file-based user import convenience. The existing users.create_from_file is deprecated (v0.41.0) in favor of bulk_add, but bulk_add takes Iterable[UserItem] and has no file-reading equivalent. Callers who want "read this CSV, import users, tell me what happened" today have to hand-roll validation + iteration + error accumulation.

Proposed shape

def bulk_add_from_file(
    self,
    filepath: str,
    strict: bool = False,
) -> tuple[JobItem, list[SkippedLine]]:
    """
    Import users from a CSV file.

    - Reads the file
    - Validates each line via UserItem.CSVImport.validate_file_for_import
    - If strict=True: raises ValueError on the first invalid line
    - If strict=False: skips invalid lines, returns them in the second tuple element
    - Calls POST /users/import (via bulk_add) with the valid users
    - Returns the JobItem plus any client-side-rejected lines
    """

SkippedLine would be a small dataclass carrying the raw line, line number, and validation error.

Motivation

  • tabcmd (createsiteusers, createusers, addusers, etc.) currently duplicates ~100 lines of CSV parsing and validation logic client-side because there's no TSC method that spans file → server. #1809 tracks bringing tabcmd onto the shared TSC implementation; this method is what tabcmd would call.
  • Direct TSC users get the same convenience.
  • strict mode gives callers the choice between fail-fast and gather-errors, matching tabcmd's existing --complete / --no-complete CLI flag.
Dominant language
Python
Stars
716
Forks
446
Avg merge
8d 8h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tableau/server-client-python

All issues in tableau/server-client-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.