Best Python code snippet using dbt-osmosis_python
osmosis.py
Source: osmosis.py
...297 # TODO: we can decide to reinit the Adapter here298 return False299 logger().info("Heartbeat received for %s", self.project_name)300 return True301 def fn_threaded_conn(self, fn: Callable[..., T], *args, **kwargs) -> Callable[..., T]:302 """Used for jobs which are intended to be submitted to a thread pool,303 the 'master' thread should always have an available connection for the duration of304 typical program runtime by virtue of the `_verify_connection` method.305 Threads however require singleton seeding"""306 def _with_conn() -> T:307 self.adapter.connections.set_connection_name()308 return fn(*args, **kwargs)309 return _with_conn310 @property311 def project_name(self) -> str:312 """dbt project name"""313 return self.config.project_name314 @property315 def project_root(self) -> str:...
server_v2.py
Source: server_v2.py
...92 )93 try:94 loop = asyncio.get_running_loop()95 result = await loop.run_in_executor(96 None, project.fn_threaded_conn(project.execute_sql, query_with_limit)97 )98 except Exception as execution_err:99 return OsmosisErrorContainer(100 error=OsmosisError(101 code=OsmosisErrorCode.ExecuteSqlFailure,102 message=str(execution_err),103 data=execution_err.__dict__,104 )105 )106 # Re-extract compiled query and return data structure107 compiled_query = re.search(108 r"select \* from \(([\w\W]+)\) as osmosis_query", result.compiled_sql109 ).groups()[0]110 return OsmosisRunResult(111 rows=[list(row) for row in result.table.rows],112 column_names=result.table.column_names,113 compiled_sql=compiled_query.strip()[1:-1],114 raw_sql=query,115 )116@app.post(117 "/compile",118 response_model=Union[OsmosisCompileResult, OsmosisErrorContainer],119 responses={120 status.HTTP_404_NOT_FOUND: {"model": OsmosisErrorContainer},121 status.HTTP_500_INTERNAL_SERVER_ERROR: {"model": OsmosisErrorContainer},122 },123 openapi_extra={124 "requestBody": {125 "content": {"text/plain": {"schema": {"type": "string"}}},126 "required": True,127 },128 },129)130async def compile_sql(131 request: Request,132 response: Response,133 x_dbt_project: str = Header(default=DEFAULT),134) -> Union[OsmosisCompileResult, OsmosisErrorContainer]:135 """Compile dbt SQL against a registered project as determined by X-dbt-Project header"""136 dbt: DbtProjectContainer = app.state.dbt_project_container137 if x_dbt_project == DEFAULT:138 project = dbt.get_default_project()139 else:140 project = dbt.get_project(x_dbt_project)141 if project is None:142 response.status_code = status.HTTP_404_NOT_FOUND143 return OsmosisErrorContainer(144 error=OsmosisError(145 code=OsmosisErrorCode.ProjectNotRegistered,146 message="Project is not registered. Make a POST request to the /register endpoint first to register a runner",147 data={"registered_projects": dbt.registered_projects()},148 )149 )150 # Query Compilation151 query: str = (await request.body()).decode("utf-8").strip()152 if has_jinja(query):153 try:154 loop = asyncio.get_running_loop()155 compiled_query = (156 await loop.run_in_executor(157 None, project.fn_threaded_conn(project.compile_sql, query)158 )159 ).compiled_sql160 except Exception as compile_err:161 response.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR162 return OsmosisErrorContainer(163 error=OsmosisError(164 code=OsmosisErrorCode.CompileSqlFailure,165 message=str(compile_err),166 data=compile_err.__dict__,167 )168 )169 else:170 compiled_query = query171 return OsmosisCompileResult(result=compiled_query)...
Check out the latest blogs from LambdaTest on this topic:
Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.
When most firms employed a waterfall development model, it was widely joked about in the industry that Google kept its products in beta forever. Google has been a pioneer in making the case for in-production testing. Traditionally, before a build could go live, a tester was responsible for testing all scenarios, both defined and extempore, in a testing environment. However, this concept is evolving on multiple fronts today. For example, the tester is no longer testing alone. Developers, designers, build engineers, other stakeholders, and end users, both inside and outside the product team, are testing the product and providing feedback.
Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.
In 2007, Steve Jobs launched the first iPhone, which revolutionized the world. But because of that, many businesses dealt with the problem of changing the layout of websites from desktop to mobile by delivering completely different mobile-compatible websites under the subdomain of ‘m’ (e.g., https://m.facebook.com). And we were all trying to figure out how to work in this new world of contending with mobile and desktop screen sizes.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!