mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 23:09:35 +01:00
run: add cmdfile
Fixes #299 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
from dvc.command.common.base import CmdBase
|
||||
from dvc.exceptions import DvcException
|
||||
@@ -14,6 +16,37 @@ class RunError(DvcException):
|
||||
DvcException.__init__(self, 'Run error: {}'.format(msg))
|
||||
|
||||
|
||||
class CommandFile(object):
|
||||
MAGIC = 'DVC-Command-State'
|
||||
VERSION = '0.1'
|
||||
|
||||
PARAM_COMMAND = 'Command'
|
||||
PARAM_CWD = 'Cwd'
|
||||
PARAM_INPUT_FILES = 'InputFiles'
|
||||
PARAM_OUTPUT_FILES = 'OutputFiles'
|
||||
PARAM_CODE_DEPENDENCIES = 'CodeDependencies'
|
||||
PARAM_SHELL = "Shell"
|
||||
PARAM_DEPS = 'Deps'
|
||||
PARAM_PATH = 'Path'
|
||||
|
||||
def __init__(self, cmd, cwd, deps):
|
||||
self.cmd = cmd
|
||||
self.cwd = cwd
|
||||
self.deps = deps
|
||||
|
||||
@staticmethod
|
||||
def loads(data):
|
||||
return CommandFile(data.get(CommandFile.PARAM_CMD, None),
|
||||
data.get(CommandFile.PARAM_CWD, None),
|
||||
data.get(CommandFile.PARAM_DEPS, []))
|
||||
|
||||
@staticmethod
|
||||
def load(fname):
|
||||
with open(fname, 'r') as fd:
|
||||
data = yaml.load(fd)
|
||||
return CommandFile.loads(data)
|
||||
|
||||
|
||||
class CmdRun(CmdBase):
|
||||
def __init__(self, settings):
|
||||
super(CmdRun, self).__init__(settings)
|
||||
|
||||
Reference in New Issue
Block a user