MCPcopy Create free account
hub / github.com/mlco2/codecarbon / create_new_config_file

Function create_new_config_file

codecarbon/cli/cli_utils.py:83–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81
82
83def create_new_config_file():
84 typer.echo("Creating new config file")
85 file_path = typer.prompt(
86 "Where do you want to put your config file ?",
87 type=str,
88 default="~/.codecarbon.config",
89 )
90 if file_path[0] == "~":
91 file_path = Path.home() / file_path[2:]
92 else:
93 file_path = Path(file_path)
94
95 if not file_path.parent.exists():
96 create = Confirm.ask(
97 "Parent folder does not exist do you want to create it (and parents) ?"
98 )
99 if create:
100 file_path.parent.mkdir(parents=True, exist_ok=True)
101
102 file_path.touch()
103 with open(file_path, "w") as f:
104 f.write("[codecarbon]\n")
105 typer.echo(f"Config file created at {file_path}")
106 return file_path

Callers 1

configFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…