Changeset View
Changeset View
Standalone View
Standalone View
python_modules/automation/automation/graphql/python_client/query.py
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | missing_query_history_subdirs = [ | ||||
for (query_name, query_present) in query_directories_present.items() | for (query_name, query_present) in query_directories_present.items() | ||||
if not query_present | if not query_present | ||||
] | ] | ||||
if missing_query_history_subdirs: | if missing_query_history_subdirs: | ||||
raise Exception( | raise Exception( | ||||
"Missing some query history (sub)directories:" | "Missing some query history (sub)directories:" | ||||
f"\n\t{missing_query_history_subdirs}" | f"\n\t{missing_query_history_subdirs}" | ||||
+ f"\n\t at {legacy_query_info.directory}" | + f"\n\t at {legacy_query_info.directory}" | ||||
+ "\n\t Please run `dagster-graphql-client query snapshot` on the command line" | + "\n\t Please run `dagster-graphql-client query snapshot` on the command line " | ||||
+ "or manually resolve these issues" | + "or manually resolve these issues" | ||||
) | ) | ||||
for query_name in query_directories_present: | for query_name in query_directories_present: | ||||
query_dir = os.path.join(legacy_query_info.directory, query_name) | query_dir = os.path.join(legacy_query_info.directory, query_name) | ||||
query_is_present = False | query_is_present = False | ||||
for filename in os.listdir(query_dir): | for filename in os.listdir(query_dir): | ||||
file_path = os.path.join(query_dir, filename) | file_path = os.path.join(query_dir, filename) | ||||
with open(file_path, "r") as f: | with open(file_path, "r") as f: | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | for (current_query_name, current_query_body) in get_queries().items(): | ||||
] | ] | ||||
) | ) | ||||
most_recent_query_filename = serialize_to_query_filename( | most_recent_query_filename = serialize_to_query_filename( | ||||
last_dagster_version, last_date.strftime(DATE_FORMAT_STRING) | last_dagster_version, last_date.strftime(DATE_FORMAT_STRING) | ||||
) | ) | ||||
with open(os.path.join(query_dir, most_recent_query_filename), "r") as f: | with open(os.path.join(query_dir, most_recent_query_filename), "r") as f: | ||||
most_recent_query = f.read() | most_recent_query = f.read() | ||||
if most_recent_query is not None and not are_queries_compatible( | if most_recent_query is None or not are_queries_compatible( | ||||
johann: A comment would help me, not sure what's happening here | |||||
current_query_body, most_recent_query | current_query_body, most_recent_query | ||||
): | ): | ||||
query_filename = serialize_to_query_filename( | query_filename = serialize_to_query_filename( | ||||
dagster_graphql.__version__, datetime.today().strftime(DATE_FORMAT_STRING) | dagster_graphql.__version__, datetime.today().strftime(DATE_FORMAT_STRING) | ||||
) | ) | ||||
query_full_file_path = os.path.join(query_dir, query_filename) | query_full_file_path = os.path.join(query_dir, query_filename) | ||||
click.echo( | click.echo( | ||||
f"Writing the dagster_graphql.client.client_queries.{current_query_name}" | f"Writing the dagster_graphql.client.client_queries.{current_query_name}" | ||||
+ f" query to a file: {query_full_file_path}" | + f" query to a file: {query_full_file_path}" | ||||
) | ) | ||||
with open(query_full_file_path, "w") as f: | with open(query_full_file_path, "w") as f: | ||||
f.write(current_query_body) | f.write(current_query_body) | ||||
click.echo("Dagster GraphQL Client query snapshot complete!") | click.echo("Dagster GraphQL Client query snapshot complete!") |
A comment would help me, not sure what's happening here