iiegn commited on
Commit
9dea85f
·
verified ·
1 Parent(s): 2bd7ed5

tools: harden path handling and align docs/options

Browse files
ADDING_NEW_UD_VERSION.md CHANGED
@@ -244,7 +244,7 @@ du -sh ../parquet/
244
  uv run ./05_validate_parquet.py --local --test
245
 
246
  # Full validation (optional, takes ~30-60 minutes)
247
- uv run ./05_validate_parquet.py --local --mode text -vv > /tmp/parquet-check.log
248
 
249
  # Check for errors (excluding metadata comments)
250
  grep -E " [+-]" /tmp/parquet-check.log | grep -vE " [+-]#"
@@ -424,7 +424,7 @@ If you need to preserve artifacts for debugging:
424
  **Symptoms:**
425
  ```
426
  ITEM DELETED - no summary: UD_Language-Treebank
427
- ITEM DELETED - no files : UD_Language-Treebank
428
  ITEM DELETED - no license: UD_Language-Treebank
429
  ```
430
 
@@ -490,7 +490,7 @@ Before marking the release as complete:
490
 
491
  - [ ] `.env` file updated with new version
492
  - [ ] Metadata files generated (`citation-{VER}`, `description-{VER}`, `codes_and_flags-{VER}.yaml`)
493
- - [ ] All UD repositories fetched and checked out to correct tag
494
  - [ ] `metadata-{VER}.json` generated with blocked treebank info
495
  - [ ] `README-{VER}` generated
496
  - [ ] Parquet files generated for all non-blocked treebanks
 
244
  uv run ./05_validate_parquet.py --local --test
245
 
246
  # Full validation (optional, takes ~30-60 minutes)
247
+ uv run ./05_validate_parquet.py --local -vv > /tmp/parquet-check.log
248
 
249
  # Check for errors (excluding metadata comments)
250
  grep -E " [+-]" /tmp/parquet-check.log | grep -vE " [+-]#"
 
424
  **Symptoms:**
425
  ```
426
  ITEM DELETED - no summary: UD_Language-Treebank
427
+ ITEM DELETED - no files: UD_Language-Treebank
428
  ITEM DELETED - no license: UD_Language-Treebank
429
  ```
430
 
 
490
 
491
  - [ ] `.env` file updated with new version
492
  - [ ] Metadata files generated (`citation-{VER}`, `description-{VER}`, `codes_and_flags-{VER}.yaml`)
493
+ - [ ] UD snapshot downloaded and `UD_repos` symlink points to `ud-treebanks-v{VER}`
494
  - [ ] `metadata-{VER}.json` generated with blocked treebank info
495
  - [ ] `README-{VER}` generated
496
  - [ ] Parquet files generated for all non-blocked treebanks
tools/00_fetch_ud_clarin-dspace_metadata.py CHANGED
@@ -28,11 +28,11 @@ description_url_prefix = "https://lindat.mff.cuni.cz/repository/server/api/core/
28
  handle_url_prefix = "http://hdl.handle.net/"
29
  handle_redirect_url_prefix = "https://lindat.mff.cuni.cz/repository/items/"
30
 
31
- # OUTPUTFILE(s) directories
32
- outfile_pathprefix = "./etc/"
33
  citation_outfile_name = "citation-{rev}"
34
  description_outfile_name = "description-{rev}"
35
- release_handle_map_file = Path(__file__).parent / "etc" / "ud_release_handles.tsv"
36
 
37
  def load_release_handles(path: Path) -> dict[str, str]:
38
  """
@@ -73,6 +73,8 @@ try:
73
  except (OSError, ValueError) as e:
74
  raise SystemExit(f"Failed to load release-handle mapping from {release_handle_map_file}: {e}")
75
 
 
 
76
  # Iterate over the URL postfixes
77
  for rev,handle in url_postfixes.items():
78
 
@@ -98,9 +100,9 @@ for rev,handle in url_postfixes.items():
98
  metadata.split("\n")])
99
 
100
  # Open the output file in write mode
101
- output_fn = f"{outfile_pathprefix}"+citation_outfile_name.format(rev=rev)
102
- if args.override or not Path(output_fn).exists():
103
- with open(output_fn, "w") as fh:
104
  fh.write(metadata + "\n")
105
  logging.info(f"Successfully downloaded citation from {citation_url} and written to {output_fn}.")
106
  else:
@@ -122,9 +124,9 @@ for rev,handle in url_postfixes.items():
122
  if description:
123
 
124
  # Open the output file in write mode
125
- output_fn = f"{outfile_pathprefix}"+description_outfile_name.format(rev=rev)
126
- if args.override or not Path(output_fn).exists():
127
- with open(output_fn, "w") as fh:
128
  fh.write(description+ "\n")
129
  logging.info(f"Successfully downloaded description from {description_url} and written to {output_fn}.")
130
  else:
 
28
  handle_url_prefix = "http://hdl.handle.net/"
29
  handle_redirect_url_prefix = "https://lindat.mff.cuni.cz/repository/items/"
30
 
31
+ TOOLS_DIR = Path(__file__).resolve().parent
32
+ OUTPUT_DIR = TOOLS_DIR / "etc"
33
  citation_outfile_name = "citation-{rev}"
34
  description_outfile_name = "description-{rev}"
35
+ release_handle_map_file = OUTPUT_DIR / "ud_release_handles.tsv"
36
 
37
  def load_release_handles(path: Path) -> dict[str, str]:
38
  """
 
73
  except (OSError, ValueError) as e:
74
  raise SystemExit(f"Failed to load release-handle mapping from {release_handle_map_file}: {e}")
75
 
76
+ OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
77
+
78
  # Iterate over the URL postfixes
79
  for rev,handle in url_postfixes.items():
80
 
 
100
  metadata.split("\n")])
101
 
102
  # Open the output file in write mode
103
+ output_fn = OUTPUT_DIR / citation_outfile_name.format(rev=rev)
104
+ if args.override or not output_fn.exists():
105
+ with output_fn.open("w") as fh:
106
  fh.write(metadata + "\n")
107
  logging.info(f"Successfully downloaded citation from {citation_url} and written to {output_fn}.")
108
  else:
 
124
  if description:
125
 
126
  # Open the output file in write mode
127
+ output_fn = OUTPUT_DIR / description_outfile_name.format(rev=rev)
128
+ if args.override or not output_fn.exists():
129
+ with output_fn.open("w") as fh:
130
  fh.write(description+ "\n")
131
  logging.info(f"Successfully downloaded description from {description_url} and written to {output_fn}.")
132
  else:
tools/01_fetch_ud_snapshot.sh CHANGED
@@ -9,15 +9,17 @@
9
 
10
  set -euo pipefail
11
 
12
- [ -e .env ] && . .env
 
 
 
 
13
 
14
  ONLINE_MODE=false
15
  KEEP_ARCHIVE=false
16
  KEEP_BACKUP=false
17
  UD_VER=${UD_VER:-"2.17"}
18
- UDS_SUBDIR="UD_repos"
19
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20
- HANDLE_MAP_FILE="${SCRIPT_DIR}/etc/ud_release_handles.tsv"
21
 
22
  ###################
23
  #############
@@ -94,8 +96,9 @@ if [[ -z "${HANDLE}" ]]; then
94
  exit 1
95
  fi
96
 
97
- SNAPSHOT_DIR="ud-treebanks-v${UD_VER}"
98
- SNAPSHOT_ARCHIVE="${SNAPSHOT_DIR}.zip"
 
99
  SNAPSHOT_URL="https://hdl.handle.net/${HANDLE}/allzip"
100
 
101
  download_snapshot() {
@@ -117,7 +120,7 @@ PY
117
  extract_snapshot() {
118
  local tmp_dir backup_dir
119
  tmp_dir=$(mktemp -d)
120
- echo "Extracting ${SNAPSHOT_ARCHIVE} into ${SNAPSHOT_DIR}"
121
 
122
  if command -v unzip >/dev/null 2>&1; then
123
  unzip -q "${SNAPSHOT_ARCHIVE}" -d "${tmp_dir}"
@@ -141,10 +144,10 @@ PY
141
  if [[ -d "${SNAPSHOT_DIR}" ]]; then
142
  if [[ "${KEEP_BACKUP}" == true ]]; then
143
  backup_dir="${SNAPSHOT_DIR}.bak.$(date +%s)"
144
- echo "Existing ${SNAPSHOT_DIR} found; moving it to ${backup_dir}"
145
  mv "${SNAPSHOT_DIR}" "${backup_dir}"
146
  else
147
- echo "Existing ${SNAPSHOT_DIR} found; removing it"
148
  rm -rf "${SNAPSHOT_DIR}"
149
  fi
150
  fi
@@ -161,22 +164,22 @@ if [[ "${ONLINE_MODE}" == true ]] || [[ ! -d "${SNAPSHOT_DIR}" ]]; then
161
  fi
162
  extract_snapshot
163
  else
164
- echo "Snapshot directory already exists: ${SNAPSHOT_DIR}"
165
  fi
166
 
167
  if [[ "${KEEP_ARCHIVE}" != true ]] && [[ -f "${SNAPSHOT_ARCHIVE}" ]]; then
168
- echo "Removing archive ${SNAPSHOT_ARCHIVE}"
169
  rm -f "${SNAPSHOT_ARCHIVE}"
170
  fi
171
 
172
  if [[ -L "${UDS_SUBDIR}" ]]; then
173
- ln -sfn "${SNAPSHOT_DIR}" "${UDS_SUBDIR}"
174
  elif [[ ! -e "${UDS_SUBDIR}" ]]; then
175
- ln -s "${SNAPSHOT_DIR}" "${UDS_SUBDIR}"
176
  else
177
  >&2 echo "${UDS_SUBDIR} exists and is not a symlink. Please move/remove it, then rerun."
178
  exit 1
179
  fi
180
 
181
  echo "UD snapshot ready:"
182
- echo " ${UDS_SUBDIR} -> ${SNAPSHOT_DIR}"
 
9
 
10
  set -euo pipefail
11
 
12
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+ ENV_FILE="${SCRIPT_DIR}/.env"
14
+ HANDLE_MAP_FILE="${SCRIPT_DIR}/etc/ud_release_handles.tsv"
15
+
16
+ [ -e "${ENV_FILE}" ] && . "${ENV_FILE}"
17
 
18
  ONLINE_MODE=false
19
  KEEP_ARCHIVE=false
20
  KEEP_BACKUP=false
21
  UD_VER=${UD_VER:-"2.17"}
22
+ UDS_SUBDIR="${SCRIPT_DIR}/UD_repos"
 
 
23
 
24
  ###################
25
  #############
 
96
  exit 1
97
  fi
98
 
99
+ SNAPSHOT_DIR_NAME="ud-treebanks-v${UD_VER}"
100
+ SNAPSHOT_DIR="${SCRIPT_DIR}/${SNAPSHOT_DIR_NAME}"
101
+ SNAPSHOT_ARCHIVE="${SCRIPT_DIR}/${SNAPSHOT_DIR_NAME}.zip"
102
  SNAPSHOT_URL="https://hdl.handle.net/${HANDLE}/allzip"
103
 
104
  download_snapshot() {
 
120
  extract_snapshot() {
121
  local tmp_dir backup_dir
122
  tmp_dir=$(mktemp -d)
123
+ echo "Extracting ${SNAPSHOT_ARCHIVE} into ${SNAPSHOT_DIR_NAME}"
124
 
125
  if command -v unzip >/dev/null 2>&1; then
126
  unzip -q "${SNAPSHOT_ARCHIVE}" -d "${tmp_dir}"
 
144
  if [[ -d "${SNAPSHOT_DIR}" ]]; then
145
  if [[ "${KEEP_BACKUP}" == true ]]; then
146
  backup_dir="${SNAPSHOT_DIR}.bak.$(date +%s)"
147
+ echo "Existing ${SNAPSHOT_DIR_NAME} found; moving it to ${backup_dir}"
148
  mv "${SNAPSHOT_DIR}" "${backup_dir}"
149
  else
150
+ echo "Existing ${SNAPSHOT_DIR_NAME} found; removing it"
151
  rm -rf "${SNAPSHOT_DIR}"
152
  fi
153
  fi
 
164
  fi
165
  extract_snapshot
166
  else
167
+ echo "Snapshot directory already exists: ${SNAPSHOT_DIR_NAME}"
168
  fi
169
 
170
  if [[ "${KEEP_ARCHIVE}" != true ]] && [[ -f "${SNAPSHOT_ARCHIVE}" ]]; then
171
+ echo "Removing archive ${SNAPSHOT_DIR_NAME}.zip"
172
  rm -f "${SNAPSHOT_ARCHIVE}"
173
  fi
174
 
175
  if [[ -L "${UDS_SUBDIR}" ]]; then
176
+ ln -sfn "${SNAPSHOT_DIR_NAME}" "${UDS_SUBDIR}"
177
  elif [[ ! -e "${UDS_SUBDIR}" ]]; then
178
+ ln -s "${SNAPSHOT_DIR_NAME}" "${UDS_SUBDIR}"
179
  else
180
  >&2 echo "${UDS_SUBDIR} exists and is not a symlink. Please move/remove it, then rerun."
181
  exit 1
182
  fi
183
 
184
  echo "UD snapshot ready:"
185
+ echo " UD_repos -> ${SNAPSHOT_DIR_NAME}"
tools/02_generate_metadata.py CHANGED
@@ -20,7 +20,9 @@ import yaml
20
  from dotenv import load_dotenv
21
 
22
 
23
- load_dotenv()
 
 
24
  UD_VER = os.getenv('UD_VER', "2.15")
25
 
26
  # Parse command line arguments
@@ -149,7 +151,8 @@ def traverse_directory(directory):
149
  """
150
  results = defaultdict(lambda: defaultdict(dict))
151
 
152
- with open(os.path.join('etc', f"codes_and_flags-{UD_VER}.yaml"), 'r') as file:
 
153
  codes_and_flags = yaml.safe_load(file)
154
  logging.debug(codes_and_flags)
155
 
@@ -266,19 +269,19 @@ def traverse_directory(directory):
266
  del results[item]["splits"][fileset_k]
267
 
268
  # 2. sets without a summary, files or license
269
- if not results[item]["summary"]:
270
- del results[item]
271
- logging.warning("ITEM DELETED - no summary: %s", item)
272
-
273
- if not any([value["files"] for value in
274
- results[item]["splits"].values()]):
275
- logging.debug(results[item]["splits"])
276
- del results[item]
277
- logging.warning("ITEM DELETED - no files: %s", item)
278
-
279
- if not results[item]["license"]:
 
280
  del results[item]
281
- logging.warning("ITEM DELETED - no license: %s", item)
282
 
283
  # Swap keys and key.value()["name"]; add old key as key.value()["dirname"]
284
  for key in list(results.keys()):
@@ -290,11 +293,11 @@ def traverse_directory(directory):
290
  return results
291
 
292
  if __name__ == '__main__':
293
- directory = 'UD_repos'
294
  results = traverse_directory(directory)
295
 
296
  # Load blocked treebanks and add "blocked" property
297
- blocked_treebanks_file = Path('blocked_treebanks.yaml')
298
  if blocked_treebanks_file.exists():
299
  with open(blocked_treebanks_file, 'r') as fh:
300
  blocked_data = yaml.safe_load(fh)
@@ -320,13 +323,12 @@ if __name__ == '__main__':
320
  logging.debug("Directory: %s", metadata["dirname"])
321
 
322
  # Write the metadata to json
323
- output_fn = f"metadata-{UD_VER}.json"
324
- output_path = Path(output_fn)
325
  should_write = args.override or (not output_path.exists()) or output_path.stat().st_size == 0
326
  if should_write:
327
- with open(output_fn, 'w') as fh:
328
  json.dump(results, fh, ensure_ascii=False, sort_keys=True,
329
  indent=4, separators=(',', ': '))
330
- print(f"{output_fn} written")
331
  else:
332
- logging.info(f"Output {output_fn} already exists: Not overriding.")
 
20
  from dotenv import load_dotenv
21
 
22
 
23
+ TOOLS_DIR = Path(__file__).resolve().parent
24
+
25
+ load_dotenv(TOOLS_DIR / ".env")
26
  UD_VER = os.getenv('UD_VER', "2.15")
27
 
28
  # Parse command line arguments
 
151
  """
152
  results = defaultdict(lambda: defaultdict(dict))
153
 
154
+ codes_and_flags_path = TOOLS_DIR / "etc" / f"codes_and_flags-{UD_VER}.yaml"
155
+ with codes_and_flags_path.open('r') as file:
156
  codes_and_flags = yaml.safe_load(file)
157
  logging.debug(codes_and_flags)
158
 
 
269
  del results[item]["splits"][fileset_k]
270
 
271
  # 2. sets without a summary, files or license
272
+ missing_summary = not results[item]["summary"]
273
+ missing_files = not any(value["files"] for value in results[item]["splits"].values())
274
+ missing_license = not results[item]["license"]
275
+
276
+ if missing_summary or missing_files or missing_license:
277
+ if missing_summary:
278
+ logging.warning("ITEM DELETED - no summary: %s", item)
279
+ if missing_files:
280
+ logging.debug(results[item]["splits"])
281
+ logging.warning("ITEM DELETED - no files: %s", item)
282
+ if missing_license:
283
+ logging.warning("ITEM DELETED - no license: %s", item)
284
  del results[item]
 
285
 
286
  # Swap keys and key.value()["name"]; add old key as key.value()["dirname"]
287
  for key in list(results.keys()):
 
293
  return results
294
 
295
  if __name__ == '__main__':
296
+ directory = TOOLS_DIR / 'UD_repos'
297
  results = traverse_directory(directory)
298
 
299
  # Load blocked treebanks and add "blocked" property
300
+ blocked_treebanks_file = TOOLS_DIR / 'blocked_treebanks.yaml'
301
  if blocked_treebanks_file.exists():
302
  with open(blocked_treebanks_file, 'r') as fh:
303
  blocked_data = yaml.safe_load(fh)
 
323
  logging.debug("Directory: %s", metadata["dirname"])
324
 
325
  # Write the metadata to json
326
+ output_path = TOOLS_DIR / f"metadata-{UD_VER}.json"
 
327
  should_write = args.override or (not output_path.exists()) or output_path.stat().st_size == 0
328
  if should_write:
329
+ with output_path.open('w') as fh:
330
  json.dump(results, fh, ensure_ascii=False, sort_keys=True,
331
  indent=4, separators=(',', ': '))
332
+ print(f"{output_path.name} written")
333
  else:
334
+ logging.info("Output %s already exists: Not overriding.", output_path.name)
tools/03_generate_README.py CHANGED
@@ -13,7 +13,9 @@ import jinja2
13
  from dotenv import load_dotenv
14
 
15
 
16
- load_dotenv()
 
 
17
  UD_VER = getenv('UD_VER', "2.15")
18
 
19
  # Parse command line arguments
@@ -34,21 +36,19 @@ logging.basicConfig(
34
 
35
 
36
  if __name__ == '__main__':
37
- basepath = Path(__file__).parent.relative_to(Path.cwd())
38
-
39
  # Read the metadata from json
40
- with Path(basepath, f"metadata-{UD_VER}.json").open(mode='r') as fh:
41
  metadata = json.load(fh)
42
 
43
- with Path(basepath, "etc", f"description-{UD_VER}").open(mode='r') as fh:
44
  description = (fh.read()).strip()
45
 
46
- with Path(basepath, "etc", f"citation-{UD_VER}").open(mode='r') as fh:
47
  citation = (fh.read()).strip()
48
 
49
  # Generate README from template
50
- template_fn = Path(basepath, "templates", "README.tmpl")
51
- output_fn = Path(basepath, f"README-{UD_VER}")
52
 
53
  if args.override or not output_fn.exists():
54
  with template_fn.open(mode='r') as fh:
@@ -59,6 +59,6 @@ if __name__ == '__main__':
59
  description=description,
60
  data=metadata, ud_ver=UD_VER,)
61
  fh.write(output)
62
- print(f"{output_fn} written")
63
  else:
64
- logging.info(f"Output {output_fn} already exists: Not overriding.")
 
13
  from dotenv import load_dotenv
14
 
15
 
16
+ TOOLS_DIR = Path(__file__).resolve().parent
17
+
18
+ load_dotenv(TOOLS_DIR / ".env")
19
  UD_VER = getenv('UD_VER', "2.15")
20
 
21
  # Parse command line arguments
 
36
 
37
 
38
  if __name__ == '__main__':
 
 
39
  # Read the metadata from json
40
+ with Path(TOOLS_DIR, f"metadata-{UD_VER}.json").open(mode='r') as fh:
41
  metadata = json.load(fh)
42
 
43
+ with Path(TOOLS_DIR, "etc", f"description-{UD_VER}").open(mode='r') as fh:
44
  description = (fh.read()).strip()
45
 
46
+ with Path(TOOLS_DIR, "etc", f"citation-{UD_VER}").open(mode='r') as fh:
47
  citation = (fh.read()).strip()
48
 
49
  # Generate README from template
50
+ template_fn = Path(TOOLS_DIR, "templates", "README.tmpl")
51
+ output_fn = Path(TOOLS_DIR, f"README-{UD_VER}")
52
 
53
  if args.override or not output_fn.exists():
54
  with template_fn.open(mode='r') as fh:
 
59
  description=description,
60
  data=metadata, ud_ver=UD_VER,)
61
  fh.write(output)
62
+ print(f"{output_fn.name} written")
63
  else:
64
+ logging.info("Output %s already exists: Not overriding.", output_fn.name)
tools/04_generate_parquet.py CHANGED
@@ -29,6 +29,7 @@ Note for developers:
29
  import argparse
30
  import os
31
  import sys
 
32
 
33
  from dotenv import load_dotenv
34
  from _ud_hfp_wrapper import (
@@ -39,8 +40,8 @@ from _ud_hfp_wrapper import (
39
  )
40
 
41
 
42
- # Load environment variables
43
- load_dotenv()
44
  UD_VER = os.getenv("UD_VER", "2.17")
45
 
46
  # Project paths
@@ -60,6 +61,8 @@ def main():
60
  parser.add_argument("-q", "--quiet", action="store_true", help="Quiet mode")
61
 
62
  args = parser.parse_args()
 
 
63
 
64
  # Use default blocked treebanks file if not specified
65
  blocked_treebanks_path = args.blocked_treebanks or str(PATHS.blocked_treebanks_file)
@@ -68,7 +71,7 @@ def main():
68
  tool_args = [
69
  "ud-hfp-tools",
70
  "generate",
71
- "--metadata", str(PATHS.metadata_file),
72
  "--ud-repos-dir", str(PATHS.ud_repos_dir),
73
  "--output-dir", str(PATHS.parquet_dir),
74
  "--blocked-treebanks", blocked_treebanks_path,
 
29
  import argparse
30
  import os
31
  import sys
32
+ from pathlib import Path
33
 
34
  from dotenv import load_dotenv
35
  from _ud_hfp_wrapper import (
 
40
  )
41
 
42
 
43
+ # Load environment variables from tools/.env
44
+ load_dotenv(Path(__file__).with_name(".env"))
45
  UD_VER = os.getenv("UD_VER", "2.17")
46
 
47
  # Project paths
 
61
  parser.add_argument("-q", "--quiet", action="store_true", help="Quiet mode")
62
 
63
  args = parser.parse_args()
64
+ versioned_metadata = Path(__file__).resolve().parent / f"metadata-{UD_VER}.json"
65
+ metadata_path = versioned_metadata if versioned_metadata.exists() else PATHS.metadata_file
66
 
67
  # Use default blocked treebanks file if not specified
68
  blocked_treebanks_path = args.blocked_treebanks or str(PATHS.blocked_treebanks_file)
 
71
  tool_args = [
72
  "ud-hfp-tools",
73
  "generate",
74
+ "--metadata", str(metadata_path),
75
  "--ud-repos-dir", str(PATHS.ud_repos_dir),
76
  "--output-dir", str(PATHS.parquet_dir),
77
  "--blocked-treebanks", blocked_treebanks_path,
tools/05_validate_parquet.py CHANGED
@@ -45,6 +45,7 @@ Note for developers:
45
  import argparse
46
  import os
47
  import sys
 
48
 
49
  from dotenv import load_dotenv
50
  from _ud_hfp_wrapper import (
@@ -55,8 +56,8 @@ from _ud_hfp_wrapper import (
55
  )
56
 
57
 
58
- # Load environment variables
59
- load_dotenv()
60
  UD_VER = os.getenv("UD_VER", "2.17")
61
 
62
  # Project paths
@@ -79,7 +80,9 @@ def main():
79
  parser.add_argument("-q", "--quiet", action="store_true", help="Quiet mode")
80
 
81
  args = parser.parse_args()
82
- metadata_path = args.metadata or str(PATHS.metadata_file)
 
 
83
 
84
  # Build arguments for ud-hf-parquet-tools
85
  tool_args = [
 
45
  import argparse
46
  import os
47
  import sys
48
+ from pathlib import Path
49
 
50
  from dotenv import load_dotenv
51
  from _ud_hfp_wrapper import (
 
56
  )
57
 
58
 
59
+ # Load environment variables from tools/.env
60
+ load_dotenv(Path(__file__).with_name(".env"))
61
  UD_VER = os.getenv("UD_VER", "2.17")
62
 
63
  # Project paths
 
80
  parser.add_argument("-q", "--quiet", action="store_true", help="Quiet mode")
81
 
82
  args = parser.parse_args()
83
+ versioned_metadata = Path(__file__).resolve().parent / f"metadata-{UD_VER}.json"
84
+ default_metadata = versioned_metadata if versioned_metadata.exists() else PATHS.metadata_file
85
+ metadata_path = args.metadata or str(default_metadata)
86
 
87
  # Build arguments for ud-hf-parquet-tools
88
  tool_args = [
tools/README.md CHANGED
@@ -73,6 +73,7 @@ git add ../parquet ../README.md ../metadata.json
73
  - Wrapper script calling `ud-hf-parquet-tools` library
74
  - Converts CoNLL-U files to Parquet format
75
  - Creates: `../parquet/{treebank}/{split}.parquet`
 
76
  - Options: `--test`, `--overwrite`, `--blocked-treebanks`
77
 
78
  ### 05 - Validate Parquet
@@ -80,7 +81,8 @@ git add ../parquet ../README.md ../metadata.json
80
  **05_validate_parquet.py**
81
  - Wrapper script calling `ud-hf-parquet-tools` library
82
  - Validates Parquet files against CoNLL-U source
83
- - Options: `--local`, `--test`, `--mode text`
 
84
 
85
  ## Directory Structure
86
 
 
73
  - Wrapper script calling `ud-hf-parquet-tools` library
74
  - Converts CoNLL-U files to Parquet format
75
  - Creates: `../parquet/{treebank}/{split}.parquet`
76
+ - Uses `tools/metadata-{UD_VER}.json` when present; otherwise falls back to `../metadata.json`
77
  - Options: `--test`, `--overwrite`, `--blocked-treebanks`
78
 
79
  ### 05 - Validate Parquet
 
81
  **05_validate_parquet.py**
82
  - Wrapper script calling `ud-hf-parquet-tools` library
83
  - Validates Parquet files against CoNLL-U source
84
+ - Uses `tools/metadata-{UD_VER}.json` when present; otherwise falls back to `../metadata.json`
85
+ - Options: `--local`, `--parquet-dir`, `--revision`, `--test`, `-vv`
86
 
87
  ## Directory Structure
88