def __init__(self, __root__): if isinstance(__root__, Path): object.__setattr__(self, 'file', FilePath.validate(__root__)) __root__ = None self._grid_out: Optional[GridOut] super().__init__(__root__=__root__)
def __init__(self, __root__): if isinstance(__root__, Path): object.__setattr__(self, 'file', FilePath.validate(__root__)) object.__setattr__(self, '_gridfs_out', None) __root__ = None if isinstance(__root__, ObjectId): if _fs.exists(__root__): object.__setattr__(self, 'file', None) object.__setattr__(self, '_gridfs_out', _fs.get(__root__)) super().__init__(__root__=__root__)
def localpath(self) -> Path: """Validates local filepath in workspace from filename. Raise 404 if filepath doesn't exist in workspace. :return: filepath for flow yaml """ try: return FilePath.validate( Path(get_workspace_path(self.workspace_id, self.filename)) ) except PathNotAFileError as e: raise HTTPException( status_code=HTTPStatus.NOT_FOUND, detail=f'File `{self.filename}` not found in workspace `{self.workspace_id}`', )
def __get_validators__(cls): yield from EnvExpand.__get_validators__() yield from FilePath.__get_validators__()