dvc-utils 0.0.9__py3-none-any.whl → 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dvc_utils/cli.py CHANGED
@@ -4,7 +4,8 @@ from typing import Tuple
4
4
 
5
5
  import click
6
6
  from click import option, argument, group
7
- from utz import diff_cmds, process, err
7
+ from utz import process, err
8
+ from qmdx import join_pipelines
8
9
 
9
10
  from dvc_utils.path import dvc_paths, dvc_path as dvc_cache_path
10
11
 
@@ -62,39 +63,32 @@ def dvc_utils_diff(
62
63
  raise ValueError(f"Invalid refspec: {refspec}")
63
64
 
64
65
  log = err if verbose else False
65
- before_path = dvc_cache_path(before, dvc_path, log=log)
66
- after_path = path if after is None else dvc_cache_path(after, dvc_path, log=log)
67
-
66
+ path1 = dvc_cache_path(before, dvc_path, log=log)
67
+ path2 = path if after is None else dvc_cache_path(after, dvc_path, log=log)
68
+
69
+ diff_args = [
70
+ *(['-w'] if ignore_whitespace else []),
71
+ *(['-U', str(unified)] if unified is not None else []),
72
+ *(['--color=always'] if color else []),
73
+ ]
68
74
  if cmds:
69
75
  cmd, *sub_cmds = cmds
76
+ cmds1 = [ f'{cmd} {path1}', *sub_cmds ]
77
+ cmds2 = [ f'{cmd} {path2}', *sub_cmds ]
70
78
  if not shell:
71
- sub_cmds = [ shlex.split(c) for c in sub_cmds ]
72
- before_cmds = [
73
- shlex.split(f'{cmd} {before_path}'),
74
- *sub_cmds,
75
- ]
76
- after_cmds = [
77
- shlex.split(f'{cmd} {after_path}'),
78
- *sub_cmds,
79
- ]
80
- shell_kwargs = {}
81
- else:
82
- before_cmds = [ f'{cmd} {before_path}', *sub_cmds ]
83
- after_cmds = [ f'{cmd} {after_path}', *sub_cmds ]
84
- shell_kwargs = dict(shell=shell)
85
-
86
- diff_cmds(
87
- before_cmds,
88
- after_cmds,
79
+ cmds1 = [ shlex.split(cmd) for cmd in cmds1 ]
80
+ cmds2 = [ shlex.split(cmd) for cmd in cmds2 ]
81
+
82
+ join_pipelines(
83
+ base_cmd=['diff', *diff_args],
84
+ cmds1=cmds1,
85
+ cmds2=cmds2,
89
86
  verbose=verbose,
90
- color=color,
91
- unified=unified,
92
- ignore_whitespace=ignore_whitespace,
87
+ shell=shell,
93
88
  shell_executable=shell_executable,
94
- **shell_kwargs,
95
89
  )
96
90
  else:
97
- process.run('diff', before_path, after_path, log=log)
91
+ process.run('diff', *diff_args, path1, path2, log=log)
98
92
 
99
93
 
100
94
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dvc-utils
3
- Version: 0.0.9
3
+ Version: 0.1.0
4
4
  Summary: CLI for diffing DVC files at two commits (or one commit vs. current worktree), optionally passing both through another command first
5
5
  Home-page: https://github.com/runsascoded/dvc-utils
6
6
  Author: Ryan Williams
@@ -8,10 +8,16 @@ Author-email: ryan@runsascoded.com
8
8
  License: MIT
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
+ Requires-Dist: click
12
+ Requires-Dist: pyyaml
13
+ Requires-Dist: qmdx
14
+ Requires-Dist: utz>=0.11.3
11
15
 
12
16
  # dvc-utils
13
17
  Diff [DVC] files, optionally piping through other commands first.
14
18
 
19
+ [![dvc-utils on PyPI](https://img.shields.io/pypi/v/dvc-utils?label=dvc-utils)][PyPI]
20
+
15
21
  <!-- toc -->
16
22
  - [Installation](#installation)
17
23
  - [Usage](#usage)
@@ -246,7 +252,7 @@ pel "ddcr $r guc h1 spc kq kcr snc 'sdf seds' sort"
246
252
 
247
253
  <details>
248
254
  <summary>
249
- Aliases used in the pipeline:
255
+ Explanation of aliases
250
256
  </summary>
251
257
 
252
258
  - [`gdno`] (`git diff --name-only`): list files changed in the given commit range and directory
@@ -254,9 +260,9 @@ Aliases used in the pipeline:
254
260
  - [`ddcr`] (`dvc-diff -cr`): colorized `diff` output, revision range `$r`
255
261
  - [`guc`] (`gunzip -c`): uncompress the `.csv.gz` files
256
262
  - [`h1`] (`head -n1`): only examine each file's header line
257
- - [`spc`] (`tr , $'\n'`): split the header line by commas (so each column name will be on one line, for easier `diff`ing below)
258
- - [`kq`] (`tr -d '"'`): kill quote characters (in this case, header-column name quoting changed, but I don't care about that)
259
- - [`kcr`] (`tr -d '\r'`): kill carriage returns (line endings also changed)
263
+ - [`spc`] (`tr , $'\n'`): **sp**lit the header line by **c**ommas (so each column name will be on one line, for easier `diff`ing below)
264
+ - [`kq`] (`tr -d '"'`): **k**ill **q**uote characters (in this case, header-column name quoting changed, but I don't care about that)
265
+ - [`kcr`] (`tr -d '\r'`): **k**ill **c**arriage **r**eturns (line endings also changed)
260
266
  - [`snc`] (`sed -f 'snake_case.sed'`): snake-case column names
261
267
  - [`sdf`] (`sed -f`): execute the `sed` substitution commands defined in the `seds` file above
262
268
  - `sort`: sort the column names alphabetically (to identify missing or added columns, ignore rearrangements)
@@ -311,6 +317,7 @@ s3/ctbk/csvs/202003-citibike-tripdata.csv.gz.dvc:
311
317
  This helped me see that the data update in question (`c0..c1`) dropped some fields (`bikeid, birth_year`, `gender`, `tripduration`) and added others (`ride_id`, `rideable_type`), for `202001` and later.
312
318
 
313
319
  [DVC]: https://dvc.org/
320
+ [PyPI]: https://pypi.org/project/dvc-utils/
314
321
  [`parquet2json`]: https://github.com/jupiter/parquet2json
315
322
  [hudcostreets/nj-crashes]: https://github.com/hudcostreets/nj-crashes
316
323
  [Parquet]: https://parquet.apache.org/
@@ -0,0 +1,9 @@
1
+ dvc_utils/__init__.py,sha256=mP-p1Sl2JMMShM_hRhu86pFNfIq_8E_feh1CN47LWcs,86
2
+ dvc_utils/cli.py,sha256=CcOa5Qmkry3PASz8nu_XqcBB6GnGmcf0e8zsuqSDsCM,3534
3
+ dvc_utils/path.py,sha256=PoAbeaqRPDksY2hcUeF8xZ6Nr6hLIZprey3VNT4V5bc,1727
4
+ dvc_utils-0.1.0.dist-info/LICENSE,sha256=ZS8AReay7xmQzBAHwxIuTouGXz3SKgUa2_Sz8Ip0EzQ,1070
5
+ dvc_utils-0.1.0.dist-info/METADATA,sha256=F3GUp8NMg0oEqsqtI_jECiWkoO7-sGYb8KJT4upGqNM,11722
6
+ dvc_utils-0.1.0.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
7
+ dvc_utils-0.1.0.dist-info/entry_points.txt,sha256=luxCQr8OS-jMSyyDhB9KDQhUbP8UH6UMcy-vkfXX7Gg,88
8
+ dvc_utils-0.1.0.dist-info/top_level.txt,sha256=jT0-PJa2t_eFRE9rn-52AjdnZ8nQeEHllf2kJmaGh80,10
9
+ dvc_utils-0.1.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- dvc_utils/__init__.py,sha256=mP-p1Sl2JMMShM_hRhu86pFNfIq_8E_feh1CN47LWcs,86
2
- dvc_utils/cli.py,sha256=D5GGDPpMlKG-8IHkTXPIB2z-QAKHzbm5gQXqj7vCquY,3701
3
- dvc_utils/path.py,sha256=PoAbeaqRPDksY2hcUeF8xZ6Nr6hLIZprey3VNT4V5bc,1727
4
- dvc_utils-0.0.9.dist-info/LICENSE,sha256=ZS8AReay7xmQzBAHwxIuTouGXz3SKgUa2_Sz8Ip0EzQ,1070
5
- dvc_utils-0.0.9.dist-info/METADATA,sha256=zhFkhQbnbOYwwhHJiXUj8otqRw5tfmVsXx-b5MlByvw,11480
6
- dvc_utils-0.0.9.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
7
- dvc_utils-0.0.9.dist-info/entry_points.txt,sha256=luxCQr8OS-jMSyyDhB9KDQhUbP8UH6UMcy-vkfXX7Gg,88
8
- dvc_utils-0.0.9.dist-info/top_level.txt,sha256=jT0-PJa2t_eFRE9rn-52AjdnZ8nQeEHllf2kJmaGh80,10
9
- dvc_utils-0.0.9.dist-info/RECORD,,