garf-executors 0.1.2__tar.gz → 0.1.4__tar.gz

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.
Files changed (25) hide show
  1. {garf_executors-0.1.2 → garf_executors-0.1.4}/PKG-INFO +1 -1
  2. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/__init__.py +10 -3
  3. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/api_executor.py +0 -18
  4. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/entrypoints/cli.py +18 -2
  5. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/execution_context.py +2 -2
  6. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/executor.py +18 -0
  7. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors.egg-info/PKG-INFO +1 -1
  8. {garf_executors-0.1.2 → garf_executors-0.1.4}/README.md +0 -0
  9. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/bq_executor.py +0 -0
  10. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/config.py +0 -0
  11. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/entrypoints/__init__.py +0 -0
  12. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/entrypoints/server.py +0 -0
  13. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/entrypoints/tracer.py +0 -0
  14. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/entrypoints/utils.py +0 -0
  15. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/exceptions.py +0 -0
  16. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/fetchers.py +0 -0
  17. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/sql_executor.py +0 -0
  18. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors/telemetry.py +0 -0
  19. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors.egg-info/SOURCES.txt +0 -0
  20. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors.egg-info/dependency_links.txt +0 -0
  21. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors.egg-info/entry_points.txt +0 -0
  22. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors.egg-info/requires.txt +0 -0
  23. {garf_executors-0.1.2 → garf_executors-0.1.4}/garf_executors.egg-info/top_level.txt +0 -0
  24. {garf_executors-0.1.2 → garf_executors-0.1.4}/pyproject.toml +0 -0
  25. {garf_executors-0.1.2 → garf_executors-0.1.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: garf-executors
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Executes queries against API and writes data to local/remote storage.
5
5
  Author-email: "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>, Andrei Markin <andrey.markin.ppc@gmail.com>
6
6
  License: Apache 2.0
@@ -24,7 +24,10 @@ from garf_executors.telemetry import tracer
24
24
 
25
25
  @tracer.start_as_current_span('setup_executor')
26
26
  def setup_executor(
27
- source: str, fetcher_parameters: dict[str, str]
27
+ source: str,
28
+ fetcher_parameters: dict[str, str | int | bool],
29
+ enable_cache: bool = False,
30
+ cache_ttl_seconds: int = 3600,
28
31
  ) -> type[executor.Executor]:
29
32
  """Initializes executors based on a source and parameters."""
30
33
  if source == 'bq':
@@ -40,7 +43,11 @@ def setup_executor(
40
43
  else:
41
44
  concrete_api_fetcher = fetchers.get_report_fetcher(source)
42
45
  query_executor = ApiQueryExecutor(
43
- concrete_api_fetcher(**fetcher_parameters)
46
+ concrete_api_fetcher(
47
+ **fetcher_parameters,
48
+ enable_cache=enable_cache,
49
+ cache_ttl_seconds=cache_ttl_seconds,
50
+ )
44
51
  )
45
52
  return query_executor
46
53
 
@@ -50,4 +57,4 @@ __all__ = [
50
57
  'ApiExecutionContext',
51
58
  ]
52
59
 
53
- __version__ = '0.1.2'
60
+ __version__ = '0.1.4'
@@ -62,24 +62,6 @@ class ApiQueryExecutor(executor.Executor):
62
62
  concrete_api_fetcher = fetchers.get_report_fetcher(source)
63
63
  return ApiQueryExecutor(concrete_api_fetcher(**fetcher_parameters))
64
64
 
65
- async def aexecute(
66
- self,
67
- query: str,
68
- title: str,
69
- context: ApiExecutionContext,
70
- ) -> str:
71
- """Performs query execution asynchronously.
72
-
73
- Args:
74
- query: Location of the query.
75
- title: Name of the query.
76
- context: Query execution context.
77
-
78
- Returns:
79
- Result of writing the report.
80
- """
81
- return await asyncio.to_thread(self.execute, query, title, context)
82
-
83
65
  @tracer.start_as_current_span('api.execute')
84
66
  def execute(
85
67
  self,
@@ -56,7 +56,17 @@ def main():
56
56
  parser.add_argument(
57
57
  '--parallel-threshold', dest='parallel_threshold', default=10, type=int
58
58
  )
59
+ parser.add_argument(
60
+ '--enable-cache', dest='enable_cache', action='store_true'
61
+ )
62
+ parser.add_argument(
63
+ '--cache-ttl-seconds',
64
+ dest='cache_ttl_seconds',
65
+ default=3600,
66
+ type=int,
67
+ )
59
68
  parser.set_defaults(parallel_queries=True)
69
+ parser.set_defaults(enable_cache=False)
60
70
  parser.set_defaults(dry_run=False)
61
71
  args, kwargs = parser.parse_known_args()
62
72
 
@@ -79,7 +89,10 @@ def main():
79
89
  f'No execution context found for source {args.source} in {config_file}'
80
90
  )
81
91
  query_executor = garf_executors.setup_executor(
82
- args.source, context.fetcher_parameters
92
+ source=args.source,
93
+ fetcher_parameters=context.fetcher_parameters,
94
+ enable_cache=args.enable_cache,
95
+ cache_ttl_seconds=args.cache_ttl_seconds,
83
96
  )
84
97
  batch = {query: reader_client.read(query) for query in args.query}
85
98
  query_executor.execute_batch(batch, context, args.parallel_threshold)
@@ -99,7 +112,10 @@ def main():
99
112
  fetcher_parameters=source_parameters,
100
113
  )
101
114
  query_executor = garf_executors.setup_executor(
102
- args.source, context.fetcher_parameters
115
+ source=args.source,
116
+ fetcher_parameters=context.fetcher_parameters,
117
+ enable_cache=args.enable_cache,
118
+ cache_ttl_seconds=args.cache_ttl_seconds,
103
119
  )
104
120
  if args.parallel_queries:
105
121
  logger.info('Running queries in parallel')
@@ -42,8 +42,8 @@ class ExecutionContext(pydantic.BaseModel):
42
42
  query_parameters: query_editor.GarfQueryParameters | None = pydantic.Field(
43
43
  default_factory=dict
44
44
  )
45
- fetcher_parameters: dict[str, str | list[str | int]] | None = pydantic.Field(
46
- default_factory=dict
45
+ fetcher_parameters: dict[str, str | bool | int | list[str | int]] | None = (
46
+ pydantic.Field(default_factory=dict)
47
47
  )
48
48
  writer: str | None = None
49
49
  writer_parameters: dict[str, str] | None = pydantic.Field(
@@ -50,6 +50,24 @@ class Executor:
50
50
  )
51
51
  )
52
52
 
53
+ async def aexecute(
54
+ self,
55
+ query: str,
56
+ title: str,
57
+ context: execution_context.ExecutionContext,
58
+ ) -> str:
59
+ """Performs query execution asynchronously.
60
+
61
+ Args:
62
+ query: Location of the query.
63
+ title: Name of the query.
64
+ context: Query execution context.
65
+
66
+ Returns:
67
+ Result of writing the report.
68
+ """
69
+ return await asyncio.to_thread(self.execute, query, title, context)
70
+
53
71
  async def _run(
54
72
  self,
55
73
  batch: dict[str, str],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: garf-executors
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Executes queries against API and writes data to local/remote storage.
5
5
  Author-email: "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>, Andrei Markin <andrey.markin.ppc@gmail.com>
6
6
  License: Apache 2.0
File without changes
File without changes