forked from PrefectHQ/prefect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefect Cloud Handoff (PrefectHQ#313)
* Configure file read toml * Intermittent commit before merge * Flow runnin in container! * Minor changes * Removed config var * Logging * Env config changes * Intermittent commit before merge * Flows CLI touchup * CLI and GQL work * Black formatting * Prefect version tag in docker image * Flow execution local loading and env changes * Flow Run ID * Black formatting; * Branch in dockerfile * Added task and flow running callbacks * Black formatting * Config access * Env config holding * Black formatting * Moved state setting * State result temporarily set to none * Debug * More cloud debug work * Task id handle * Comment * Merge master * Readd timeout handler * Parameters adjustment * Path update * Flow run config loading * Flows cli update * Black formatting * Local execution * Black formatting * Paramater tuning * Temp empty param handling until new flow run create functionality * Black formatting * Removed loading non-existent params * Removed client initialization from task_runner * Test fixing * CLI refactor * Adjustments for server changes * CLI tweaks * Address comments * Black formatting * Removed running of flow due to scheduler existance * Scheduled flow runs * Black formatting * Added refresh_token into client.py * Handle nonetype for schedule * Task runner and flow runner callouts to prefect cloud * Remove config data in cloud context * Removed client self reference * Remove comment * Address comments * Testing option * Client call to delete flow from serialized * Adjusted to query then delete * Debugging * Debugging * Result handling * Client deleteflow change * Minor refactor * Raised on exception remove * Debugging * Revert changes
- Loading branch information
Showing
13 changed files
with
678 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,8 @@ local_settings.py | |
|
||
# Dask stuff: | ||
*dask-worker-space/* | ||
*.dirlock | ||
*.lock | ||
|
||
# Flask stuff: | ||
instance/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,89 @@ | ||
# Licensed under LICENSE.md; also available at https://www.prefect.io/licenses/alpha-eula | ||
|
||
import json | ||
import os | ||
from pathlib import Path | ||
import sys | ||
|
||
import click | ||
import toml | ||
|
||
from prefect.client import Client | ||
from prefect.utilities.cli import load_prefect_config, PATH | ||
|
||
|
||
@click.group() | ||
def configure(): | ||
""" | ||
Configure communication with Prefect Cloud | ||
Configure communication with Prefect Cloud. | ||
""" | ||
pass | ||
|
||
|
||
@configure.command() | ||
@click.argument("path", required=False) | ||
def init(path): | ||
def init(): | ||
""" | ||
Initialize cloud communication config options | ||
Initialize cloud communication config options. | ||
""" | ||
config_data = load_prefect_config() | ||
|
||
if not path: | ||
path = "{}/.prefect/config.toml".format(os.getenv("HOME")) | ||
|
||
if Path(path).is_file(): | ||
config_data = toml.load(path) | ||
else: | ||
config_data = {} | ||
|
||
# Do under .server block | ||
config_data["REGISTRY_URL"] = click.prompt( | ||
"Registry URL", default=config_data.get("REGISTRY_URL") | ||
) | ||
config_data["API_URL"] = click.prompt("API URL", default=config_data.get("API_URL")) | ||
config_data["API_ACCESS_KEY"] = click.prompt( | ||
"API Access Key", default=config_data.get("API_ACCESS_KEY") | ||
) | ||
|
||
toml.dump(config_data, path) | ||
with open(PATH, "w") as config_file: | ||
toml.dump(config_data, config_file) | ||
|
||
|
||
@configure.command() | ||
@click.argument("variable") | ||
@click.argument("path", required=False) | ||
def set_variable(variable, path): | ||
def set_variable(variable): | ||
""" | ||
Sets a specific configuration variable | ||
Sets a specific configuration variable. | ||
""" | ||
if not path: | ||
path = "{}/.prefect/config.toml".format(os.getenv("HOME")) | ||
|
||
if Path(path).is_file(): | ||
config_data = toml.load(path) | ||
else: | ||
config_data = {} | ||
config_data = load_prefect_config() | ||
|
||
config_data[variable] = click.prompt( | ||
"{}".format(variable), default=config_data.get(variable) | ||
) | ||
|
||
toml.dump(config_data, path) | ||
with open(PATH, "w") as config_file: | ||
toml.dump(config_data, config_file) | ||
|
||
|
||
@configure.command() | ||
@click.argument("path", required=False) | ||
def list_config(path): | ||
def list_config(): | ||
""" | ||
List all configuration variables | ||
List all configuration variables. | ||
""" | ||
if not path: | ||
path = "{}/.prefect/config.toml".format(os.getenv("HOME")) | ||
|
||
if Path(path).is_file(): | ||
config_data = toml.load(path) | ||
else: | ||
config_data = {} | ||
config_data = load_prefect_config() | ||
|
||
click.echo(config_data) | ||
|
||
|
||
@configure.command() | ||
@click.argument("path", required=False) | ||
def open_config(path): | ||
def open_config(): | ||
""" | ||
Opens the configuration file. | ||
""" | ||
click.launch(PATH) | ||
|
||
|
||
@configure.command() | ||
def login(): | ||
""" | ||
Opens the configuration file | ||
Login to Prefect Cloud. | ||
""" | ||
if not path: | ||
path = "{}/.prefect/config.toml".format(os.getenv("HOME")) | ||
config_data = load_prefect_config() | ||
|
||
config_data["EMAIL"] = click.prompt("email", default=config_data.get("EMAIL")) | ||
config_data["PASSWORD"] = click.prompt( | ||
"password", hide_input=True, confirmation_prompt=True | ||
) | ||
|
||
client = Client( | ||
config_data["API_URL"], os.path.join(config_data["API_URL"], "graphql/") | ||
) | ||
|
||
client.login(email=config_data["EMAIL"], password=config_data["PASSWORD"]) | ||
|
||
click.launch(path) | ||
with open(PATH, "w") as config_file: | ||
toml.dump(config_data, config_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.