Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster-graphql/dagster_graphql/cli.py
from future.standard_library import install_aliases # isort:skip | from future.standard_library import install_aliases # isort:skip | ||||
install_aliases() # isort:skip | install_aliases() # isort:skip | ||||
import signal | import signal | ||||
import threading | |||||
import warnings | |||||
import click | import click | ||||
import requests | import requests | ||||
from graphql import graphql | from graphql import graphql | ||||
from graphql.execution.executors.gevent import GeventExecutor | from graphql.execution.executors.gevent import GeventExecutor | ||||
from graphql.execution.executors.sync import SyncExecutor | from graphql.execution.executors.sync import SyncExecutor | ||||
from dagster import check, seven | from dagster import check, seven | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | elif predefined is not None and text is None and file is None: | ||||
query = PREDEFINED_QUERIES[predefined] | query = PREDEFINED_QUERIES[predefined] | ||||
else: | else: | ||||
raise click.UsageError( | raise click.UsageError( | ||||
"Must select one and only one of text (-t), file (-f), or predefined (-p) " | "Must select one and only one of text (-t), file (-f), or predefined (-p) " | ||||
"to select GraphQL document to execute." | "to select GraphQL document to execute." | ||||
) | ) | ||||
if remap_sigterm: | if remap_sigterm: | ||||
try: | |||||
signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT)) | signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT)) | ||||
except ValueError: | |||||
warnings.warn( | |||||
( | |||||
"Unexpected error attempting to manage signal handling on thread {thread_name}. " | |||||
"You should not invoke this API (execute_run_with_structured_logs) from threads " | |||||
"other than the main thread." | |||||
).format(thread_name=threading.current_thread().name) | |||||
) | |||||
if remote: | if remote: | ||||
res = execute_query_against_remote(remote, query, variables) | res = execute_query_against_remote(remote, query, variables) | ||||
print(res) # pylint: disable=print-call | print(res) # pylint: disable=print-call | ||||
else: | else: | ||||
instance = DagsterInstance.get() | instance = DagsterInstance.get() | ||||
with get_workspace_from_kwargs(kwargs, instance) as workspace: | with get_workspace_from_kwargs(kwargs, instance) as workspace: | ||||
execute_query_from_cli( | execute_query_from_cli( | ||||
Show All 10 Lines |