Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request dbt-labs#1798 from fishtown-analytics/feature/rena…
Browse files Browse the repository at this point in the history
…me-rpc-methods

rename RPC methods (dbt-labs#1779)
  • Loading branch information
beckjake authored Oct 2, 2019
2 parents 3765435 + e61f08b commit 13a7d96
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
12 changes: 6 additions & 6 deletions core/dbt/task/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,21 @@ def handle_request(


class RemoteCompileTask(_RPCExecTask):
METHOD_NAME = 'compile'
METHOD_NAME = 'compile_sql'

def get_runner_type(self):
return RPCCompileRunner


class RemoteRunTask(_RPCExecTask, RunTask):
METHOD_NAME = 'run'
METHOD_NAME = 'run_sql'

def get_runner_type(self):
return RPCExecuteRunner


class RemoteCompileProjectTask(RPCTask):
METHOD_NAME = 'compile_project'
METHOD_NAME = 'compile'

def __init__(self, args, config, manifest):
super().__init__(args, config)
Expand All @@ -198,7 +198,7 @@ def handle_request(


class RemoteRunProjectTask(RPCTask, RunTask):
METHOD_NAME = 'run_project'
METHOD_NAME = 'run'

def __init__(self, args, config, manifest):
super().__init__(args, config)
Expand All @@ -219,7 +219,7 @@ def handle_request(


class RemoteSeedProjectTask(RPCTask, SeedTask):
METHOD_NAME = 'seed_project'
METHOD_NAME = 'seed'

def __init__(self, args, config, manifest):
super().__init__(args, config)
Expand All @@ -239,7 +239,7 @@ def handle_request(


class RemoteTestProjectTask(RPCTask, TestTask):
METHOD_NAME = 'test_project'
METHOD_NAME = 'test'

def __init__(self, args, config, manifest):
super().__init__(args, config)
Expand Down
82 changes: 41 additions & 41 deletions test/integration/048_rpc_test/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class TestRPCServer(HasRPCServer):
@use_profile('postgres')
def test_compile_postgres(self):
trivial = self.async_query(
'compile',
'compile_sql',
'select 1 as id',
name='foo'
).json()
Expand All @@ -287,7 +287,7 @@ def test_compile_postgres(self):
)

ref = self.async_query(
'compile',
'compile_sql',
'select * from {{ ref("descendant_model") }}',
name='foo'
).json()
Expand All @@ -300,7 +300,7 @@ def test_compile_postgres(self):
)

source = self.async_query(
'compile',
'compile_sql',
'select * from {{ source("test_source", "test_table") }}',
name='foo'
).json()
Expand All @@ -313,7 +313,7 @@ def test_compile_postgres(self):
)

macro = self.async_query(
'compile',
'compile_sql',
'select {{ my_macro() }}',
name='foo',
macros='{% macro my_macro() %}1 as id{% endmacro %}'
Expand All @@ -325,7 +325,7 @@ def test_compile_postgres(self):
)

macro_override = self.async_query(
'compile',
'compile_sql',
'select {{ happy_little_macro() }}',
name='foo',
macros='{% macro override_me() %}2 as id{% endmacro %}'
Expand All @@ -337,7 +337,7 @@ def test_compile_postgres(self):
)

macro_override_with_if_statement = self.async_query(
'compile',
'compile_sql',
'{% if True %}select {{ happy_little_macro() }}{% endif %}',
name='foo',
macros='{% macro override_me() %}2 as id{% endmacro %}'
Expand All @@ -349,7 +349,7 @@ def test_compile_postgres(self):
)

ephemeral = self.async_query(
'compile',
'compile_sql',
'select * from {{ ref("ephemeral_model") }}',
name='foo'
).json()
Expand All @@ -365,7 +365,7 @@ def test_run_postgres(self):
self.run_dbt_with_vars(['seed'])
self.run_dbt_with_vars(['run'])
data = self.async_query(
'run',
'run_sql',
'select 1 as id',
name='foo'
).json()
Expand All @@ -374,7 +374,7 @@ def test_run_postgres(self):
)

ref = self.async_query(
'run',
'run_sql',
'select * from {{ ref("descendant_model") }} order by updated_at limit 1',
name='foo'
).json()
Expand All @@ -391,7 +391,7 @@ def test_run_postgres(self):
)

source = self.async_query(
'run',
'run_sql',
'select * from {{ source("test_source", "test_table") }} order by updated_at limit 1',
name='foo'
).json()
Expand All @@ -408,7 +408,7 @@ def test_run_postgres(self):
)

macro = self.async_query(
'run',
'run_sql',
'select {{ my_macro() }}',
name='foo',
macros='{% macro my_macro() %}1 as id{% endmacro %}'
Expand All @@ -421,7 +421,7 @@ def test_run_postgres(self):
)

macro_override = self.async_query(
'run',
'run_sql',
'select {{ happy_little_macro() }}',
name='foo',
macros='{% macro override_me() %}2 as id{% endmacro %}'
Expand All @@ -434,7 +434,7 @@ def test_run_postgres(self):
)

macro_override_with_if_statement = self.async_query(
'run',
'run_sql',
'{% if True %}select {{ happy_little_macro() }}{% endif %}',
name='foo',
macros='{% macro override_me() %}2 as id{% endmacro %}'
Expand All @@ -447,7 +447,7 @@ def test_run_postgres(self):
)

macro_with_raw_statement = self.async_query(
'run',
'run_sql',
'{% raw %}select 1 as{% endraw %}{{ test_macros() }}{% macro test_macros() %} id{% endmacro %}',
name='foo'
).json()
Expand All @@ -459,7 +459,7 @@ def test_run_postgres(self):
)

macro_with_comment = self.async_query(
'run',
'run_sql',
'{% raw %}select 1 {% endraw %}{{ test_macros() }} {# my comment #}{% macro test_macros() -%} as{% endmacro %} id{# another comment #}',
name='foo'
).json()
Expand All @@ -471,7 +471,7 @@ def test_run_postgres(self):
)

ephemeral = self.async_query(
'run',
'run_sql',
'select * from {{ ref("ephemeral_model") }}',
name='foo'
).json()
Expand All @@ -484,7 +484,7 @@ def test_run_postgres(self):

def _get_sleep_query(self, duration=15, request_id=90890):
sleep_query = self.query(
'run',
'run_sql',
'select * from pg_sleep({})'.format(duration),
name='sleeper',
_test_request_id=request_id
Expand All @@ -497,7 +497,7 @@ def _get_sleep_query(self, duration=15, request_id=90890):
@mark.flaky(rerun_filter=None)
@use_profile('postgres')
def test_ps_kill_postgres(self):
done_query = self.async_query('compile', 'select 1 as id', name='done').json()
done_query = self.async_query('compile_sql', 'select 1 as id', name='done').json()
self.assertIsResult(done_query)

request_token, request_id = self._get_sleep_query()
Expand All @@ -511,7 +511,7 @@ def test_ps_kill_postgres(self):
self.assertEqual(len(result['rows']), 1)
rowdict = result['rows']
self.assertEqual(rowdict[0]['request_id'], request_id)
self.assertEqual(rowdict[0]['method'], 'run')
self.assertEqual(rowdict[0]['method'], 'run_sql')
self.assertEqual(rowdict[0]['state'], 'running')
self.assertIsNone(rowdict[0]['timeout'])
self.assertEqual(rowdict[0]['task_id'], request_token)
Expand All @@ -522,7 +522,7 @@ def test_ps_kill_postgres(self):
self.assertEqual(len(result['rows']), 1)
rowdict = result['rows']
self.assertEqual(rowdict[0]['request_id'], 1)
self.assertEqual(rowdict[0]['method'], 'compile')
self.assertEqual(rowdict[0]['method'], 'compile_sql')
self.assertEqual(rowdict[0]['state'], 'success')
self.assertIsNone(rowdict[0]['timeout'])
self.assertGreater(rowdict[0]['elapsed'], 0)
Expand All @@ -533,12 +533,12 @@ def test_ps_kill_postgres(self):
rowdict = result['rows']
rowdict.sort(key=lambda r: r['start'])
self.assertEqual(rowdict[0]['request_id'], 1)
self.assertEqual(rowdict[0]['method'], 'compile')
self.assertEqual(rowdict[0]['method'], 'compile_sql')
self.assertEqual(rowdict[0]['state'], 'success')
self.assertIsNone(rowdict[0]['timeout'])
self.assertGreater(rowdict[0]['elapsed'], 0)
self.assertEqual(rowdict[1]['request_id'], request_id)
self.assertEqual(rowdict[1]['method'], 'run')
self.assertEqual(rowdict[1]['method'], 'run_sql')
self.assertEqual(rowdict[1]['state'], 'running')
self.assertIsNone(rowdict[1]['timeout'])
self.assertGreater(rowdict[1]['elapsed'], 0)
Expand All @@ -557,12 +557,12 @@ def test_ps_kill_postgres(self):
rowdict = result['rows']
rowdict.sort(key=lambda r: r['start'])
self.assertEqual(rowdict[0]['request_id'], 1)
self.assertEqual(rowdict[0]['method'], 'compile')
self.assertEqual(rowdict[0]['method'], 'compile_sql')
self.assertEqual(rowdict[0]['state'], 'success')
self.assertIsNone(rowdict[0]['timeout'])
self.assertGreater(rowdict[0]['elapsed'], 0)
self.assertEqual(rowdict[1]['request_id'], request_id)
self.assertEqual(rowdict[1]['method'], 'run')
self.assertEqual(rowdict[1]['method'], 'run_sql')
self.assertEqual(rowdict[1]['state'], 'error')
self.assertIsNone(rowdict[1]['timeout'])
self.assertGreater(rowdict[1]['elapsed'], 0)
Expand Down Expand Up @@ -607,7 +607,7 @@ def test_invalid_requests_postgres(self):
self.assertIsErrorWith(data, -32601, 'Method not found', None)

data = self.async_query(
'compile',
'compile_sql',
'select * from {{ reff("nonsource_descendant") }}',
name='mymodel'
).json()
Expand All @@ -621,7 +621,7 @@ def test_invalid_requests_postgres(self):
self.assertTrue(len(error_data['logs']) > 0)

data = self.async_query(
'run',
'run_sql',
'hi this is not sql',
name='foo'
).json()
Expand All @@ -635,7 +635,7 @@ def test_invalid_requests_postgres(self):
self.assertTrue(len(error_data['logs']) > 0)

macro_no_override = self.async_query(
'run',
'run_sql',
'select {{ happy_little_macro() }}',
name='foo',
).json()
Expand All @@ -658,7 +658,7 @@ def assertHasErrorData(self, error, expected_error_data):
@use_profile('postgres')
def test_timeout_postgres(self):
data = self.async_query(
'run',
'run_sql',
'select from pg_sleep(5)',
name='foo',
timeout=1
Expand All @@ -678,7 +678,7 @@ def test_timeout_postgres(self):
def test_seed_project_postgres(self):
# testing "dbt seed" is tricky so we'll just jam some sql in there
self.run_sql_file("seed.sql")
result = self.async_query('seed_project', show=True).json()
result = self.async_query('seed', show=True).json()
dct = self.assertIsResult(result)
self.assertTablesEqual('source', 'seed_expected')
self.assertIn('results', dct)
Expand All @@ -692,7 +692,7 @@ def test_seed_project_postgres(self):
@use_profile('postgres')
def test_compile_project_postgres(self):
self.run_dbt_with_vars(['seed'])
result = self.async_query('compile_project').json()
result = self.async_query('compile').json()
dct = self.assertIsResult(result)
self.assertIn('results', dct)
results = dct['results']
Expand All @@ -706,7 +706,7 @@ def test_compile_project_postgres(self):
@use_profile('postgres')
def test_run_project_postgres(self):
self.run_dbt_with_vars(['seed'])
result = self.async_query('run_project').json()
result = self.async_query('run').json()
dct = self.assertIsResult(result)
self.assertIn('results', dct)
results = dct['results']
Expand All @@ -720,9 +720,9 @@ def test_run_project_postgres(self):
@use_profile('postgres')
def test_test_project_postgres(self):
self.run_dbt_with_vars(['seed'])
result = self.async_query('run_project').json()
result = self.async_query('run').json()
dct = self.assertIsResult(result)
result = self.async_query('test_project').json()
result = self.async_query('test').json()
dct = self.assertIsResult(result)
self.assertIn('results', dct)
results = dct['results']
Expand Down Expand Up @@ -763,7 +763,7 @@ def assertRunning(self, sleepers):
for _, request_id in sleepers:
found = result_map[request_id]
self.assertEqual(found['request_id'], request_id)
self.assertEqual(found['method'], 'run')
self.assertEqual(found['method'], 'run_sql')
self.assertEqual(found['state'], 'running')
self.assertEqual(found['timeout'], None)

Expand All @@ -783,17 +783,17 @@ def test_sighup_postgres(self):

self.assertIn('timestamp', status)

done_query = self.async_query('compile', 'select 1 as id', name='done').json()
done_query = self.async_query('compile_sql', 'select 1 as id', name='done').json()
self.assertIsResult(done_query)
sleepers = []
command_ids = []

sleepers.append(self._get_sleep_query(duration=60, request_id=1000))
self.assertRunning(sleepers)

self._add_command('seed_project', 20)
self._add_command('seed', 20)
command_ids.append(20)
self._add_command('run_project', 21)
self._add_command('run', 21)
command_ids.append(21)

# sighup a few times
Expand All @@ -805,9 +805,9 @@ def test_sighup_postgres(self):
# we should still still see our service:
self.assertRunning(sleepers)

self._add_command('seed_project', 30)
self._add_command('seed', 30)
command_ids.append(30)
self._add_command('run_project', 31)
self._add_command('run', 31)
command_ids.append(31)

# start a new one too
Expand All @@ -825,7 +825,7 @@ def test_sighup_postgres(self):
def _make_any_requests(self, num_requests):
stored = []
for idx in range(num_requests):
response = self.query('run', 'select 1 as id', name='run').json()
response = self.query('run_sql', 'select 1 as id', name='run').json()
result = self.assertIsResult(response)
self.assertIn('request_token', result)
token = result['request_token']
Expand Down Expand Up @@ -951,7 +951,7 @@ def test_postgres_status_error(self):
self.assertIn('error', status)
self.assertIn('message', status['error'])

compile_result = self.query('compile', 'select 1 as id').json()
compile_result = self.query('compile_sql', 'select 1 as id').json()
data = self.assertIsErrorWith(
compile_result,
10011,
Expand Down

0 comments on commit 13a7d96

Please sign in to comment.