dbimport.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:GenomicsSampleAPIs 作者: Intel-HLS 项目源码 文件源码
def registerWorkspace(self, guid, name):
        """
        Registers a workspace.
        Workspace name is the path to the workspace directory. This is assumed unique per metadb instance.
        """

        # if the name ends with a / then remove it from the name.
        # This is done only for consistency in workspace name
        # since users could have / or not for the workspace.
        name = name.rstrip('/')

        workspace = self.session.query(Workspace).filter(
            and_(Workspace.name == name))\
            .first()

        if workspace is None:
            try:
                workspace = Workspace(
                    guid=guid, 
                    name=name
                )
                self.session.add(workspace)
                self.session.commit()

            except exc.DataError as e:
                self.session.rollback()
                raise ValueError("{0} : {1} ".format(str(e), guid))

        return workspace
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号