tinybird 0.0.1.dev0__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.

Potentially problematic release.


This version of tinybird might be problematic. Click here for more details.

Files changed (45) hide show
  1. tinybird/__cli__.py +8 -0
  2. tinybird/ch_utils/constants.py +244 -0
  3. tinybird/ch_utils/engine.py +855 -0
  4. tinybird/check_pypi.py +25 -0
  5. tinybird/client.py +1281 -0
  6. tinybird/config.py +117 -0
  7. tinybird/connectors.py +428 -0
  8. tinybird/context.py +23 -0
  9. tinybird/datafile.py +5589 -0
  10. tinybird/datatypes.py +434 -0
  11. tinybird/feedback_manager.py +1022 -0
  12. tinybird/git_settings.py +145 -0
  13. tinybird/sql.py +865 -0
  14. tinybird/sql_template.py +2343 -0
  15. tinybird/sql_template_fmt.py +281 -0
  16. tinybird/sql_toolset.py +350 -0
  17. tinybird/syncasync.py +682 -0
  18. tinybird/tb_cli.py +25 -0
  19. tinybird/tb_cli_modules/auth.py +252 -0
  20. tinybird/tb_cli_modules/branch.py +1043 -0
  21. tinybird/tb_cli_modules/cicd.py +434 -0
  22. tinybird/tb_cli_modules/cli.py +1571 -0
  23. tinybird/tb_cli_modules/common.py +2082 -0
  24. tinybird/tb_cli_modules/config.py +344 -0
  25. tinybird/tb_cli_modules/connection.py +803 -0
  26. tinybird/tb_cli_modules/datasource.py +900 -0
  27. tinybird/tb_cli_modules/exceptions.py +91 -0
  28. tinybird/tb_cli_modules/fmt.py +91 -0
  29. tinybird/tb_cli_modules/job.py +85 -0
  30. tinybird/tb_cli_modules/pipe.py +858 -0
  31. tinybird/tb_cli_modules/regions.py +9 -0
  32. tinybird/tb_cli_modules/tag.py +100 -0
  33. tinybird/tb_cli_modules/telemetry.py +310 -0
  34. tinybird/tb_cli_modules/test.py +107 -0
  35. tinybird/tb_cli_modules/tinyunit/tinyunit.py +340 -0
  36. tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +71 -0
  37. tinybird/tb_cli_modules/token.py +349 -0
  38. tinybird/tb_cli_modules/workspace.py +269 -0
  39. tinybird/tb_cli_modules/workspace_members.py +212 -0
  40. tinybird/tornado_template.py +1194 -0
  41. tinybird-0.0.1.dev0.dist-info/METADATA +2815 -0
  42. tinybird-0.0.1.dev0.dist-info/RECORD +45 -0
  43. tinybird-0.0.1.dev0.dist-info/WHEEL +5 -0
  44. tinybird-0.0.1.dev0.dist-info/entry_points.txt +2 -0
  45. tinybird-0.0.1.dev0.dist-info/top_level.txt +4 -0
@@ -0,0 +1,145 @@
1
+ from dataclasses import dataclass
2
+ from enum import Enum
3
+ from typing import Dict, NamedTuple, Optional
4
+
5
+ from tinybird.tb_cli_modules.cicd import (
6
+ APPEND_FIXTURES_SH,
7
+ DEFAULT_REQUIREMENTS_FILE,
8
+ EXEC_TEST_SH,
9
+ GITHUB_CD_YML,
10
+ GITHUB_CI_YML,
11
+ GITHUB_RELEASES_YML,
12
+ WORKFLOW_VERSION,
13
+ )
14
+
15
+
16
+ class GitProviders(Enum):
17
+ GITHUB = "github"
18
+
19
+
20
+ class GitHubResource(NamedTuple):
21
+ resource_id: str
22
+ resource_name: str
23
+ resource_type: str
24
+ path: str
25
+ sha: str
26
+ mode: str = "100644"
27
+ type: str = "blob"
28
+ origin: Optional[str] = ""
29
+
30
+
31
+ class GitHubSettingsStatus(Enum):
32
+ IDLE = "idle" # Nothing yet
33
+ LINKED = "linked" # Connection flow has started
34
+ SYNCED = "synced" # Repository is synced
35
+ SYNCING = "syncing" # Repository is syncing
36
+ UNLINKED = "unlinked" # Connection has been removed
37
+ CLI = "cli" # Connection has been made through the CLI
38
+
39
+
40
+ @dataclass
41
+ class GitHubSettings:
42
+ provider: Optional[str] = ""
43
+ owner: Optional[str] = ""
44
+ owner_type: Optional[str] = ""
45
+ remote: Optional[str] = ""
46
+ access_token: Optional[str] = ""
47
+ branch: Optional[str] = ""
48
+ project_path: Optional[str] = ""
49
+ name: Optional[str] = ""
50
+ status: Optional[str] = GitHubSettingsStatus.IDLE.value
51
+
52
+
53
+ AVAILABLE_GIT_PROVIDERS = [GitProviders.GITHUB.value]
54
+
55
+ DEFAULT_BRANCH = "main"
56
+
57
+ CI_WORKFLOW_VERSION = WORKFLOW_VERSION
58
+
59
+ DEFAULT_TINYENV_FILE = """
60
+ VERSION=0.0.0
61
+
62
+
63
+
64
+ ##########
65
+ # OPTIONAL env vars
66
+
67
+ # Don't print CLI version warning message if there's a new available version
68
+ # TB_VERSION_WARNING=0
69
+
70
+ # Skip regression tests
71
+ # TB_SKIP_REGRESSION=0
72
+
73
+ # Use `OBFUSCATE_REGEX_PATTERN` and `OBFUSCATE_PATTERN_SEPARATOR` environment variables to define a regex pattern and a separator (in case of a single string with multiple regex) to obfuscate secrets in the CLI output.
74
+ # OBFUSCATE_REGEX_PATTERN="https://(www\.)?[^/]+||^Follow these instructions =>"
75
+ # OBFUSCATE_PATTERN_SEPARATOR=||
76
+ ##########
77
+ """
78
+
79
+ GITHUB_DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
80
+
81
+ GITHUB_DEFAULT_EMPTY_TREE_HASH = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
82
+
83
+ DEFAULT_INIT_FILES = {
84
+ "requirements.txt": DEFAULT_REQUIREMENTS_FILE,
85
+ ".tinyenv": DEFAULT_TINYENV_FILE,
86
+ "scripts/exec_test.sh": EXEC_TEST_SH,
87
+ "scripts/append_fixtures.sh": APPEND_FIXTURES_SH,
88
+ "datasources/.gitkeep": "",
89
+ "datasources/fixtures/.gitkeep": "",
90
+ "pipes/.gitkeep": "",
91
+ "endpoints/.gitkeep": "",
92
+ "deploy/.gitkeep": "",
93
+ "tests/.gitkeep": "",
94
+ }
95
+
96
+ GITHUB_CI_YML_PATH = ".github/workflows/tinybird_ci.yml"
97
+ GITHUB_CD_YML_PATH = ".github/workflows/tinybird_cd.yml"
98
+ GITHUB_RELEASES_YML_PATH = ".github/workflows/tinybird_release.yml"
99
+
100
+ DEFAULT_INIT_FILES_DEPLOY = {
101
+ GITHUB_CI_YML_PATH: GITHUB_CI_YML,
102
+ GITHUB_CD_YML_PATH: GITHUB_CD_YML,
103
+ GITHUB_RELEASES_YML_PATH: GITHUB_RELEASES_YML,
104
+ }
105
+
106
+
107
+ class SemverVersions(Enum):
108
+ MAJOR: str = "major"
109
+ MINOR: str = "minor"
110
+ PATCH: str = "patch"
111
+ CURRENT: str = "current"
112
+
113
+
114
+ def bump_version(version: str, next_version: Optional[str]) -> str:
115
+ if not next_version:
116
+ return version
117
+
118
+ parts = version.split(".")
119
+ is_valid_semver = len(parts) == 3
120
+
121
+ if is_valid_semver and next_version in [
122
+ SemverVersions.MAJOR.value,
123
+ SemverVersions.MINOR.value,
124
+ SemverVersions.PATCH.value,
125
+ ]:
126
+ major, minor, patch = map(int, parts)
127
+ if next_version == SemverVersions.MAJOR.value:
128
+ major += 1
129
+ elif next_version == SemverVersions.MINOR.value:
130
+ minor += 1
131
+ elif next_version == SemverVersions.PATCH.value:
132
+ patch += 1
133
+
134
+ return f"{major}.{minor}.{patch}"
135
+ # TODO validate next version
136
+ return next_version
137
+
138
+
139
+ def get_default_init_files_deploy(workspace_name: str) -> Dict[str, str]:
140
+ modified_files = {
141
+ path.replace("tinybird_", f"tinybird_{workspace_name.lower()}_"): content
142
+ for path, content in DEFAULT_INIT_FILES_DEPLOY.items()
143
+ }
144
+
145
+ return modified_files