Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

dvcpatch.py 1.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  1. """
  2. Support code for our custom DVC remote.
  3. """
  4. import logging
  5. from urllib.parse import urlparse
  6. import hashlib
  7. from dvc.remote.base import RemoteBASE
  8. from dvc.output.base import OutputBase
  9. from dvc.dependency.base import DependencyBase
  10. from . import tracking
  11. _log = logging.getLogger('dvc.bgpatch')
  12. class PGRemote(RemoteBASE):
  13. """
  14. PG status remote
  15. """
  16. scheme = 'pgstat'
  17. PARAM_CHECKSUM = 'md5'
  18. def __init__(self, *args, **kwargs):
  19. super().__init__(*args, **kwargs)
  20. def get_file_checksum(self, path_info):
  21. _log.debug('checksum from %s', path_info)
  22. status = tracking.stage_status(path_info.bucket)
  23. h = hashlib.md5()
  24. h.update(status.encode('utf-8'))
  25. return h.hexdigest()
  26. def copy(self, from_info, to_info):
  27. _log.debug('copy from %s', from_info)
  28. _log.debug('copy to %s', to_info)
  29. raise NotImplementedError()
  30. def exists(self, path_info):
  31. _log.debug('exists? %s', path_info)
  32. return tracking.stage_exists(path_info.bucket)
  33. def remove(self, path_info):
  34. _log.info('asked to remove %s, ignoring', path_info)
  35. def _download(self, from_info, to_info, name, no_progress_bar):
  36. _log.info('download requested for %s', from_info)
  37. raise NotImplementedError()
  38. class PGOut(OutputBase):
  39. REMOTE = PGRemote
  40. class PGDep(DependencyBase, OutputBase):
  41. REMOTE = PGRemote
  42. def patch():
  43. "Patch DVC to include our classes"
  44. import dvc.output, dvc.dependency, dvc.config
  45. dvc.output.OUTS.append(PGOut)
  46. dvc.output.OUTS_MAP['pgstat'] = PGOut
  47. dvc.dependency.DEPS.append(PGDep)
  48. dvc.dependency.DEP_MAP['pgstat'] = PGDep
  49. # from dvc.cache import Cache, _make_remote_property
  50. # Cache.pgstat = _make_remote_property('pgstat')
  51. # dvc.config.Config.SCHEMA['cache']['pgstat'] = str
  52. # dvc.config.Config.COMPILED_SCHEMA = dvc.config.Schema(dvc.config.Config.SCHEMA)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...