Skip to main content

TextGrid repository administration cli tool, based on tgclients

Project description

tgadmin

A command line tool for managing your projects in the TextGrid repository without TextGridLab.

Install

You may use this with venv or with pipx. With pipx you have the benefit of having the command available in your shell without further manual venv creation and activation.

Install pipx, e.g. on Debian/Ubuntu apt install pipx.

And add this tool from pypi.org

pipx install tgadmin
# or if uv is available (to enable managed python version)
uv tool --managed-python install tgadmin
```sh

Upgrade to a new version with

```sh
pipx upgrade tgadmin

If you do not want to use pipx have a look at the section "Development".

Usage

Export sessionID (SID)

get from https://textgridlab.org/1.0/Shibboleth.sso/Login?target=/1.0/secure/TextGrid-WebAuth.php?authZinstance=textgrid-esx2.gwdg.de

and set as env var:

export TEXTGRID_SID=your_secret_sid_here

or set with --sid for every command

Get help

tgadmin

List projects

list your projects:

tgadmin list

Create project

if there is no suitable project, create one:

tgadmin create lab-import-test-20230605

Upload an aggregation object like editons, aggregations and collections

You can upload aggregations as new textgrid objects like

tgadmin --server http://test.textgridlab.org import -p TGPR-...fe eng003.edition

this would assume that you have an file containing the aggragtion with local paths in eng003.edition and metadata description files like eng003.edition.meta. After initial uploads you find an filename.imex which has a mapping of lokal file names to textgrid URIs. This can be used to update the objects from the edition like:

tgadmin --server http://test.textgridlab.org import -i eng003.edition.imex .

BYOLR (Bring Your Own Link Rewriter ;-)

We use command line tools to rewrite links in TEI and aggregations. Our default choice is linkrewriter-cli but you are free to choose anything which implements the command line interface.

To use the link rewriter cli as native build (linux amd64 only for now):

wget https://gitlab.gwdg.de/api/v4/projects/45698/packages/generic/linkrewriter/0.1.23/linkrewriter-cli
chmod +x ./linkrewriter-cli

or on non linux-amd64 systems:

wget https://gitlab.gwdg.de/api/v4/projects/45698/packages/generic/linkrewriter/0.1.23/linkrewriter-cli.jar
echo -e '#!/bin/bash\njava -jar linkrewriter-cli.jar $@' > ./linkrewriter-cli
chmod +x ./linkrewriter-cli

If you are not on linux amd64, you may use linkrewriter with java. You may create a shell script calling java -jar linkrewriter-cli.jar $# then, or build something great with jbang.

Or if you are not happy with linkrewriter results, create a shell script, utilizing e.g. sed. Just call it linkrewriter-cli and make sure it implements the cli interface

  • -i imex_file_location
  • -c config you may ignore this
  • -b base path of xml relative to the imex file location (you may ignore this too)
  • FILENAME

Advanced Usage

You may use the development or the test instance of the TextGrid Server.

To use tgadmin with the test instance do

tgadmin --server https://test.textgridlab.org list

for the dev system there is a shortcut, you may call

tgadmin --dev list

shell completion

_TGADMIN_COMPLETE=bash_source tgadmin > tgadmin-complete.bash
. tgadmin-complete.bash

Development

clone repo

git clone https://gitlab.gwdg.de/dariah-de/textgridrep/tgadmin.git
cd tgadmin

and create venv

uv venv # or python3 -m venv .venv
source .venv/bin/activate
uv pip install --editable . # or pip install --editable .[dev]

afterwards tgadmin is in your venv as command and can be executed

tgadmin

run integration tests and check coverage

WARNING: do not provide a project ID where you have data, as objects from project may accidently get removed

export PROJECT_ID=[my-project-id]
export TEXTGRID_SID=[my-session-id]
coverage run -m pytest --junitxml=report.xml && coverage html

Contributing

Commit convention:

Style constraints:

Coding constraints:

For your convenience, pre-commit hooks are configured to check against these constraints. Provided, you have installed the development requirements (see above), activate pre-commit to run on every git commit:

pre-commit install

Badges

REUSE status PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgadmin-0.38.2.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tgadmin-0.38.2-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file tgadmin-0.38.2.tar.gz.

File metadata

  • Download URL: tgadmin-0.38.2.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for tgadmin-0.38.2.tar.gz
Algorithm Hash digest
SHA256 4d0eb48a0d1efb81e3819859ab3c2d21cd535643673fd2be3bac58c834f46ea0
MD5 ef20d0089cdd5055ee6ec6891b469768
BLAKE2b-256 bb6d93148601968799ae2a9dd54c1488bff7ed32f70f8686bcf6ddddd522e5dd

See more details on using hashes here.

File details

Details for the file tgadmin-0.38.2-py3-none-any.whl.

File metadata

  • Download URL: tgadmin-0.38.2-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for tgadmin-0.38.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c2a17c215f38c7b026f3b13f359d8242ef41249d3ff7dafa59b74e12efd4c393
MD5 ed031ead751895b89b8e8c0e407ed29d
BLAKE2b-256 16823a95ad5544deb3ac01e303f6ff8dd54738ac7c047aeab8c27d19a2a314c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page