iiegn commited on
Commit
783e782
·
verified ·
1 Parent(s): 654e1a1

tools: standardize UD version flag on --ud-ver

Browse files
ADDING_NEW_UD_VERSION.md CHANGED
@@ -65,14 +65,14 @@ export NEW_VER=2.18
65
  # echo "UD_VER=${NEW_VER}" > .env
66
  ```
67
 
68
- **Recommended:** pass explicit flags (`--ud-ver` / `--rev`) in commands below.
69
  **Optional:** keep `.env` for a persistent default.
70
 
71
  ### 4. Fetch Metadata from LINDAT/CLARIN
72
 
73
  ```bash
74
  # Fetch citation and description
75
- ./00_fetch_ud_clarin-dspace_metadata.py -o -r ${NEW_VER}
76
 
77
  # This creates:
78
  # - etc/citation-2.18
@@ -93,7 +93,7 @@ export NEW_VER=2.18
93
 
94
  ```bash
95
  # Fetch language metadata
96
- ./00_fetch_ud_codes_and_flags.sh -o -r ${NEW_VER}
97
 
98
  # This creates:
99
  # - etc/codes_and_flags-2.18.yaml
@@ -118,7 +118,7 @@ Use `--all` only when you want to refresh all mapped versions.
118
 
119
  ```bash
120
  # Download and extract official UD release snapshot
121
- ./01_fetch_ud_snapshot.sh -r ${NEW_VER}
122
 
123
  # This creates/updates:
124
  # - ud-treebanks-v2.18/ (extracted snapshot directory)
@@ -407,13 +407,13 @@ This makes the new version the default when users don't specify a revision.
407
  **Solution:**
408
  ```bash
409
  cd tools
410
- ./01_fetch_ud_snapshot.sh --online --rev 2.18
411
  ls -ld UD_repos ud-treebanks-v2.18
412
  ```
413
 
414
  If you need to preserve artifacts for debugging:
415
  ```bash
416
- ./01_fetch_ud_snapshot.sh --online --rev 2.18 --keep-archive --keep-backup
417
  ```
418
 
419
  ### Issue: Metadata extraction fails for a treebank
@@ -487,7 +487,7 @@ uv run --script ./script.py
487
 
488
  Before marking the release as complete:
489
 
490
- - [ ] Version passed explicitly via flags (`--ud-ver` / `--rev`) or `.env` updated
491
  - [ ] Metadata files generated (`citation-{VER}`, `description-{VER}`, `codes_and_flags-{VER}.yaml`)
492
  - [ ] UD snapshot downloaded and `UD_repos` symlink points to `ud-treebanks-v{VER}`
493
  - [ ] `metadata-{VER}.json` generated with blocked treebank info
 
65
  # echo "UD_VER=${NEW_VER}" > .env
66
  ```
67
 
68
+ **Recommended:** pass explicit flags (`--ud-ver`) in commands below.
69
  **Optional:** keep `.env` for a persistent default.
70
 
71
  ### 4. Fetch Metadata from LINDAT/CLARIN
72
 
73
  ```bash
74
  # Fetch citation and description
75
+ ./00_fetch_ud_clarin-dspace_metadata.py -o --ud-ver ${NEW_VER}
76
 
77
  # This creates:
78
  # - etc/citation-2.18
 
93
 
94
  ```bash
95
  # Fetch language metadata
96
+ ./00_fetch_ud_codes_and_flags.sh -o --ud-ver ${NEW_VER}
97
 
98
  # This creates:
99
  # - etc/codes_and_flags-2.18.yaml
 
118
 
119
  ```bash
120
  # Download and extract official UD release snapshot
121
+ ./01_fetch_ud_snapshot.sh --ud-ver ${NEW_VER}
122
 
123
  # This creates/updates:
124
  # - ud-treebanks-v2.18/ (extracted snapshot directory)
 
407
  **Solution:**
408
  ```bash
409
  cd tools
410
+ ./01_fetch_ud_snapshot.sh --online --ud-ver 2.18
411
  ls -ld UD_repos ud-treebanks-v2.18
412
  ```
413
 
414
  If you need to preserve artifacts for debugging:
415
  ```bash
416
+ ./01_fetch_ud_snapshot.sh --online --ud-ver 2.18 --keep-archive --keep-backup
417
  ```
418
 
419
  ### Issue: Metadata extraction fails for a treebank
 
487
 
488
  Before marking the release as complete:
489
 
490
+ - [ ] Version passed explicitly via flags (`--ud-ver`) or `.env` updated
491
  - [ ] Metadata files generated (`citation-{VER}`, `description-{VER}`, `codes_and_flags-{VER}.yaml`)
492
  - [ ] UD snapshot downloaded and `UD_repos` symlink points to `ud-treebanks-v{VER}`
493
  - [ ] `metadata-{VER}.json` generated with blocked treebank info
tools/00_fetch_ud_clarin-dspace_metadata.py CHANGED
@@ -56,8 +56,10 @@ parser = argparse.ArgumentParser(description=__doc__,
56
  formatter_class=argparse.RawDescriptionHelpFormatter)
57
  parser.add_argument('-o', '--override', action='store_true',
58
  help='override output file if it already exists')
59
- parser.add_argument('-r', '--rev',
60
  help='only fetch one UD version (e.g. 2.17)')
 
 
61
  parser.add_argument('-v', '--verbose', action='count', default=0,
62
  help='increase verbosity level')
63
  args = parser.parse_args()
@@ -75,11 +77,11 @@ try:
75
  except (OSError, ValueError) as e:
76
  raise SystemExit(f"Failed to load release-handle mapping from {release_handle_map_file}: {e}")
77
 
78
- if args.rev:
79
- if args.rev not in url_postfixes:
80
  known = ", ".join(sorted(url_postfixes.keys()))
81
- raise SystemExit(f"Unknown UD version '{args.rev}'. Known versions: {known}")
82
- url_postfixes = {args.rev: url_postfixes[args.rev]}
83
 
84
  OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
85
 
 
56
  formatter_class=argparse.RawDescriptionHelpFormatter)
57
  parser.add_argument('-o', '--override', action='store_true',
58
  help='override output file if it already exists')
59
+ parser.add_argument('--ud-ver', dest='ud_ver',
60
  help='only fetch one UD version (e.g. 2.17)')
61
+ # Backward-compatible alias (hidden from --help)
62
+ parser.add_argument('-r', '--rev', dest='ud_ver', help=argparse.SUPPRESS)
63
  parser.add_argument('-v', '--verbose', action='count', default=0,
64
  help='increase verbosity level')
65
  args = parser.parse_args()
 
77
  except (OSError, ValueError) as e:
78
  raise SystemExit(f"Failed to load release-handle mapping from {release_handle_map_file}: {e}")
79
 
80
+ if args.ud_ver:
81
+ if args.ud_ver not in url_postfixes:
82
  known = ", ".join(sorted(url_postfixes.keys()))
83
+ raise SystemExit(f"Unknown UD version '{args.ud_ver}'. Known versions: {known}")
84
+ url_postfixes = {args.ud_ver: url_postfixes[args.ud_ver]}
85
 
86
  OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
87
 
tools/00_fetch_ud_codes_and_flags.sh CHANGED
@@ -33,7 +33,7 @@ VER_MAPPING["latest"]="e3847a587baa2a5a7345049b8b2c109ad2162c21"
33
  # USAGE
34
  #
35
  usage() { OUTPUT=${1:-"verbose"}
36
- echo "Usage: $0 [-o] [-r VER] [-a]" >&2
37
  [ "${OUTPUT}" = "short" ] && exit 0
38
  >&2 cat << EOF
39
 
@@ -52,7 +52,7 @@ German:
52
  Options:
53
  -h Print this help message
54
  -o|--online Enable online mode: (re-fetch files from GitHub)
55
- -r|--rev VER Download one version (default: UD_VER from .env)
56
  -a|--all Download all mapped versions
57
  EOF
58
  }
@@ -65,7 +65,7 @@ ONLINE_MODE=false
65
  ALL_MODE=false
66
  TARGET_VER="${UD_VER:-2.17}"
67
 
68
- VALID_ARGS=$(getopt -o hoar: --long help,online,all,rev: -- "$@")
69
  if [[ $? -ne 0 ]]; then
70
  usage "short"
71
  exit 1
@@ -76,7 +76,7 @@ do
76
  case "$1" in
77
  -o | --online) ONLINE_MODE=true; shift ;;
78
  -a | --all) ALL_MODE=true; shift ;;
79
- -r | --rev) TARGET_VER="$2"; shift 2 ;;
80
  -h | --help) usage; shift ; exit 0;;
81
  --) shift ; break ;;
82
  *) >&2 echo Unsupported option: $1; usage; exit 1;;
 
33
  # USAGE
34
  #
35
  usage() { OUTPUT=${1:-"verbose"}
36
+ echo "Usage: $0 [-o] [--ud-ver VER] [-a]" >&2
37
  [ "${OUTPUT}" = "short" ] && exit 0
38
  >&2 cat << EOF
39
 
 
52
  Options:
53
  -h Print this help message
54
  -o|--online Enable online mode: (re-fetch files from GitHub)
55
+ --ud-ver VER Download one version (default: UD_VER from .env)
56
  -a|--all Download all mapped versions
57
  EOF
58
  }
 
65
  ALL_MODE=false
66
  TARGET_VER="${UD_VER:-2.17}"
67
 
68
+ VALID_ARGS=$(getopt -o hoau:r: --long help,online,all,ud-ver:,rev: -- "$@")
69
  if [[ $? -ne 0 ]]; then
70
  usage "short"
71
  exit 1
 
76
  case "$1" in
77
  -o | --online) ONLINE_MODE=true; shift ;;
78
  -a | --all) ALL_MODE=true; shift ;;
79
+ -u | --ud-ver | -r | --rev) TARGET_VER="$2"; shift 2 ;;
80
  -h | --help) usage; shift ; exit 0;;
81
  --) shift ; break ;;
82
  *) >&2 echo Unsupported option: $1; usage; exit 1;;
tools/01_fetch_ud_snapshot.sh CHANGED
@@ -27,7 +27,7 @@ UDS_SUBDIR="${SCRIPT_DIR}/UD_repos"
27
  # USAGE
28
  #
29
  usage() { OUTPUT=${1:-"verbose"}
30
- echo "Usage: $0 [-o] [-r VER] [--keep-archive] [--keep-backup]" >&2
31
  [ "$OUTPUT" = "short" ] && exit 0
32
  >&2 cat << EOF
33
 
@@ -46,7 +46,7 @@ Then a symlink is created/updated:
46
  Options:
47
  -h Print this help message
48
  -o|--online Force re-download and re-extract
49
- -r|--rev VER UD version to fetch (default: \${UD_VER} from .env)
50
  --keep-archive Keep downloaded archive after extraction
51
  --keep-backup Keep existing snapshot directory as timestamped backup
52
  EOF
@@ -56,7 +56,7 @@ EOF
56
  ############
57
  ##################
58
 
59
- VALID_ARGS=$(getopt -o hor: --long help,online,rev:,keep-archive,keep-backup -- "$@")
60
  if [[ $? -ne 0 ]]; then
61
  usage "short"
62
  exit 1
@@ -67,7 +67,7 @@ while [ : ]
67
  do
68
  case "$1" in
69
  -o | --online) ONLINE_MODE=true; shift ;;
70
- -r | --rev) UD_VER="$2"; shift 2 ;;
71
  --keep-archive) KEEP_ARCHIVE=true; shift ;;
72
  --keep-backup) KEEP_BACKUP=true; shift ;;
73
  -h | --help) usage; shift ; exit 0 ;;
 
27
  # USAGE
28
  #
29
  usage() { OUTPUT=${1:-"verbose"}
30
+ echo "Usage: $0 [-o] [--ud-ver VER] [--keep-archive] [--keep-backup]" >&2
31
  [ "$OUTPUT" = "short" ] && exit 0
32
  >&2 cat << EOF
33
 
 
46
  Options:
47
  -h Print this help message
48
  -o|--online Force re-download and re-extract
49
+ --ud-ver VER UD version to fetch (default: \${UD_VER} from .env)
50
  --keep-archive Keep downloaded archive after extraction
51
  --keep-backup Keep existing snapshot directory as timestamped backup
52
  EOF
 
56
  ############
57
  ##################
58
 
59
+ VALID_ARGS=$(getopt -o hou:r: --long help,online,ud-ver:,rev:,keep-archive,keep-backup -- "$@")
60
  if [[ $? -ne 0 ]]; then
61
  usage "short"
62
  exit 1
 
67
  do
68
  case "$1" in
69
  -o | --online) ONLINE_MODE=true; shift ;;
70
+ -u | --ud-ver | -r | --rev) UD_VER="$2"; shift 2 ;;
71
  --keep-archive) KEEP_ARCHIVE=true; shift ;;
72
  --keep-backup) KEEP_BACKUP=true; shift ;;
73
  -h | --help) usage; shift ; exit 0 ;;
tools/README.md CHANGED
@@ -12,9 +12,9 @@ cd tools
12
  # echo "UD_VER=${NEW_VER}" > .env
13
 
14
  # Fetch metadata
15
- uv run 00_fetch_ud_clarin-dspace_metadata.py -o -r "${NEW_VER}"
16
- ./00_fetch_ud_codes_and_flags.sh -o -r "${NEW_VER}"
17
- ./01_fetch_ud_snapshot.sh -r "${NEW_VER}"
18
 
19
  # Generate files
20
  uv run 02_generate_metadata.py -o --ud-ver "${NEW_VER}"
@@ -38,7 +38,7 @@ git add ../parquet ../README.md ../metadata.json
38
  - Downloads citation and description from LINDAT/CLARIN repository
39
  - Creates: `etc/citation-{VER}`, `etc/description-{VER}`
40
  - Uses: `etc/ud_release_handles.tsv` for version -> handle mapping
41
- - Optional filter: `--rev {VER}` to fetch one version
42
 
43
  **00_fetch_ud_codes_and_flags.sh**
44
  - Downloads language codes and flags from UD docs-automation
@@ -52,7 +52,7 @@ git add ../parquet ../README.md ../metadata.json
52
  - Downloads official UD release snapshot from LINDAT/CLARIN (archive resolved via API)
53
  - Creates: `ud-treebanks-v{VER}/`
54
  - Creates/updates symlink: `UD_repos -> ud-treebanks-v{VER}`
55
- - Options: `--rev`, `--online`, `--keep-archive`, `--keep-backup`
56
 
57
  ### 02 - Generate Metadata
58
 
@@ -119,7 +119,7 @@ tools/
119
  ```bash
120
  UD_VER=2.17 # Current UD version
121
  ```
122
- You can skip `.env` and pass `--ud-ver`/`--rev` flags directly.
123
 
124
  **Blocked Treebanks (blocked_treebanks.yaml)**
125
  ```yaml
@@ -174,16 +174,16 @@ pip install ud-hf-parquet-tools
174
 
175
  **Snapshot download/extraction fails:**
176
  ```bash
177
- ./01_fetch_ud_snapshot.sh --online --rev 2.17
178
  ```
179
 
180
  **Disk usage after repeated snapshot refreshes:**
181
  ```bash
182
  # Default behavior deletes archive and replaces old snapshot directory
183
- ./01_fetch_ud_snapshot.sh --online --rev 2.17
184
 
185
  # Keep archive and timestamped backup only when needed
186
- ./01_fetch_ud_snapshot.sh --online --rev 2.17 --keep-archive --keep-backup
187
  ```
188
 
189
  ## Documentation
 
12
  # echo "UD_VER=${NEW_VER}" > .env
13
 
14
  # Fetch metadata
15
+ uv run 00_fetch_ud_clarin-dspace_metadata.py -o --ud-ver "${NEW_VER}"
16
+ ./00_fetch_ud_codes_and_flags.sh -o --ud-ver "${NEW_VER}"
17
+ ./01_fetch_ud_snapshot.sh --ud-ver "${NEW_VER}"
18
 
19
  # Generate files
20
  uv run 02_generate_metadata.py -o --ud-ver "${NEW_VER}"
 
38
  - Downloads citation and description from LINDAT/CLARIN repository
39
  - Creates: `etc/citation-{VER}`, `etc/description-{VER}`
40
  - Uses: `etc/ud_release_handles.tsv` for version -> handle mapping
41
+ - Optional filter: `--ud-ver {VER}` to fetch one version
42
 
43
  **00_fetch_ud_codes_and_flags.sh**
44
  - Downloads language codes and flags from UD docs-automation
 
52
  - Downloads official UD release snapshot from LINDAT/CLARIN (archive resolved via API)
53
  - Creates: `ud-treebanks-v{VER}/`
54
  - Creates/updates symlink: `UD_repos -> ud-treebanks-v{VER}`
55
+ - Options: `--ud-ver`, `--online`, `--keep-archive`, `--keep-backup`
56
 
57
  ### 02 - Generate Metadata
58
 
 
119
  ```bash
120
  UD_VER=2.17 # Current UD version
121
  ```
122
+ You can skip `.env` and pass `--ud-ver` flags directly.
123
 
124
  **Blocked Treebanks (blocked_treebanks.yaml)**
125
  ```yaml
 
174
 
175
  **Snapshot download/extraction fails:**
176
  ```bash
177
+ ./01_fetch_ud_snapshot.sh --online --ud-ver 2.17
178
  ```
179
 
180
  **Disk usage after repeated snapshot refreshes:**
181
  ```bash
182
  # Default behavior deletes archive and replaces old snapshot directory
183
+ ./01_fetch_ud_snapshot.sh --online --ud-ver 2.17
184
 
185
  # Keep archive and timestamped backup only when needed
186
+ ./01_fetch_ud_snapshot.sh --online --ud-ver 2.17 --keep-archive --keep-backup
187
  ```
188
 
189
  ## Documentation