command to start sagemaker training
include sample training
This commit is contained in:
30
src/state.py
Normal file
30
src/state.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
STATE_FILE = ".qc-cli.json"
|
||||
|
||||
|
||||
def _path(config_dir: str) -> Path:
|
||||
return Path(config_dir) / STATE_FILE
|
||||
|
||||
|
||||
def read_state(config_dir: str = ".") -> dict[str, Any]:
|
||||
path = _path(config_dir)
|
||||
if not path.exists():
|
||||
return {}
|
||||
with open(path) as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def write_state(config_dir: str = ".", **updates: str | None) -> None:
|
||||
path = _path(config_dir)
|
||||
state = read_state(config_dir)
|
||||
state.update(updates)
|
||||
with open(path, "w") as f:
|
||||
json.dump(state, f, indent=2)
|
||||
|
||||
|
||||
def get_last_training_job(config_dir: str = ".") -> str | None:
|
||||
value = read_state(config_dir).get("last_training_job")
|
||||
return str(value) if value else None
|
||||
Reference in New Issue
Block a user