(
repo: "Repo",
targets: Union["StrOrBytesPath", Iterator["StrOrBytesPath"]],
no_commit: bool = False,
glob: bool = False,
out: Optional[str] = None,
remote: Optional[str] = None,
to_remote: bool = False,
remote_jobs: Optional[int] = None,
force: bool = False,
relink: bool = True,
)
| 190 | @locked |
| 191 | @scm_context |
| 192 | def add( |
| 193 | repo: "Repo", |
| 194 | targets: Union["StrOrBytesPath", Iterator["StrOrBytesPath"]], |
| 195 | no_commit: bool = False, |
| 196 | glob: bool = False, |
| 197 | out: Optional[str] = None, |
| 198 | remote: Optional[str] = None, |
| 199 | to_remote: bool = False, |
| 200 | remote_jobs: Optional[int] = None, |
| 201 | force: bool = False, |
| 202 | relink: bool = True, |
| 203 | ) -> list["Stage"]: |
| 204 | add_targets = find_targets(targets, glob=glob) |
| 205 | if not add_targets: |
| 206 | return [] |
| 207 | |
| 208 | stages_with_targets = { |
| 209 | target: get_or_create_stage( |
| 210 | repo, |
| 211 | target, |
| 212 | out=out, |
| 213 | to_remote=to_remote, |
| 214 | force=force, |
| 215 | ) |
| 216 | for target in add_targets |
| 217 | } |
| 218 | |
| 219 | stages = [stage for stage, _ in stages_with_targets.values()] |
| 220 | msg = "Collecting stages from the workspace" |
| 221 | with translate_graph_error(stages), ui.status(msg) as st: |
| 222 | repo.check_graph(stages=stages, callback=lambda: st.update("Checking graph")) |
| 223 | |
| 224 | if to_remote or out: |
| 225 | assert len(stages_with_targets) == 1, "multiple targets are unsupported" |
| 226 | (source, (stage, _)) = next(iter(stages_with_targets.items())) |
| 227 | _add_transfer(stage, source, remote, to_remote, jobs=remote_jobs, force=force) |
| 228 | return [stage] |
| 229 | |
| 230 | with warn_link_failures() as link_failures: |
| 231 | for source, (stage, output_exists) in progress_iter(stages_with_targets): |
| 232 | try: |
| 233 | _add( |
| 234 | stage, |
| 235 | source if output_exists else None, |
| 236 | no_commit=no_commit, |
| 237 | relink=relink, |
| 238 | ) |
| 239 | except CacheLinkError: |
| 240 | link_failures.append(stage.relpath) |
| 241 | return stages |
nothing calls this directly
no test coverage detected