当前位置: 首页>>代码示例>>Python>>正文


Python GirderClient.put方法代码示例

本文整理汇总了Python中girder_client.GirderClient.put方法的典型用法代码示例。如果您正苦于以下问题:Python GirderClient.put方法的具体用法?Python GirderClient.put怎么用?Python GirderClient.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在girder_client.GirderClient的用法示例。


在下文中一共展示了GirderClient.put方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: NewtIntegrationTest

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
class NewtIntegrationTest(BaseIntegrationTest):
    def __init__(self, name, girder_url, girder_user, girder_password, machine, job_timeout=60 * 5):
        super(NewtIntegrationTest, self).__init__(name, girder_url, girder_user, girder_password, job_timeout)
        self._cluster_id = None
        self._machine = machine

    def setUp(self):

        # First authenticate with NEWT
        self._session = Session()
        r = self._session.post(
            "https://newt.nersc.gov/newt/auth", {"username": self._girder_user, "password": self._girder_password}
        )

        self.assertEqual(r.status_code, 200)
        print r.json()
        self._newt_session_id = r.json()["newt_sessionid"]

        # Now authenticate with Girder using the session id
        url = "%s/api/v1/newt/authenticate/%s" % (self._girder_url, self._newt_session_id)
        r = self._session.put(url)
        self.assertEqual(r.status_code, 200)

        url = "%s/api/v1/newt/authenticate/%s" % (self._girder_url, self._newt_session_id)
        r = self._session.put(url)
        self.assertEqual(r.status_code, 200)

        url = "%s/api/v1" % self._girder_url
        self._client = GirderClient(apiUrl=url)
        self._client.token = self._session.cookies["girderToken"]

        user = self._client.get("user/me")
        self._user_id = user["_id"]
        r = self._client.listFolder(self._user_id, "user", name="Private")
        r = list(r)
        self.assertEqual(len(r), 1)
        self._private_folder_id = r[0]["_id"]

    def tearDown(self):
        super(NewtIntegrationTest, self).tearDown()
        if self._cluster_id:
            try:
                url = "clusters/%s" % self._cluster_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

    def create_cluster(self):
        body = {"config": {"host": self._machine}, "name": "NewtIntegrationTest", "type": "newt"}

        r = self._client.post("clusters", data=json.dumps(body))
        self._cluster_id = r["_id"]

        # Now test the connection
        r = self._client.put("clusters/%s/start" % self._cluster_id)
        sleeps = 0
        while True:
            time.sleep(1)
            r = self._client.get("clusters/%s/status" % self._cluster_id)

            if r["status"] == "running":
                break
            elif r["status"] == "error":
                r = self._client.get("clusters/%s/log" % self._cluster_id)
                self.fail(str(r))

            if sleeps > 9:
                self.fail("Cluster never moved into running state")
            sleeps += 1

    def assert_output(self):
        r = self._client.listItem(self._output_folder_id)
        self.assertEqual(len(r), 4)

        stdout_item = None
        for i in r:
            if i["name"].startswith("CumulusIntegrationTestJob-%s.o" % self._job_id):
                stdout_item = i
                break

        self.assertIsNotNone(stdout_item)
        r = self._client.get("item/%s/files" % i["_id"])
        self.assertEqual(len(r), 1)

        url = "%s/api/v1/file/%s/download" % (self._girder_url, r[0]["_id"])
        r = self._session.get(url)
        self.assertEqual(r.content, self._data)

    def test(self):
        try:
            self.create_cluster()
            self.create_script()
            self.create_input()
            self.create_output_folder()
            self.create_job()
            self.submit_job(timeout=self._job_timeout)
            self.assert_output()
        except HttpError as error:
            self.fail(error.responseText)
开发者ID:Kitware,项目名称:cumulus,代码行数:101,代码来源:newt_integration_test.py

示例2: main

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
def main(config):
    client = GirderClient(apiUrl=config.girder_api_url)
    client.authenticate(config.girder_user,
                        config.girder_password)

    # Load any parameters
    params = {}
    if config.taskflow_start_params is not None:
        with open(config.taskflow_start_params) as fp:
            params = json.load(fp)

    print params

    try:
        print ('Running %s taskflow ...' % config.taskflow_start_params)
        taskflow_id = create_taskflow(
            client, config.taskflow_class)

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url, data=json.dumps(params))

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

    except HttpError as ex:
        print( ex.responseText)
开发者ID:Kitware,项目名称:HPCCloud,代码行数:29,代码来源:runner.py

示例3: _taskflow_task_finished

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
def _taskflow_task_finished(taskflow, taskflow_task_id):
    girder_token = taskflow['girder_token']
    girder_api_url = taskflow['girder_api_url']

    client = GirderClient(apiUrl=girder_api_url)
    client.token = girder_token
    url = 'taskflows/%s/tasks/%s/finished' % (taskflow.id, taskflow_task_id)

    return client.put(url)
开发者ID:Kitware,项目名称:cumulus,代码行数:11,代码来源:__init__.py

示例4: find_assetstore

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
            lastName='Admin')

client.authenticate(user, password)

s3_assetstore_name = 's3'

if find_assetstore(s3_assetstore_name) is None:
    client.post('assetstore',
                parameters=dict(name=s3_assetstore_name,
                                type=str(AssetstoreType.S3),
                                bucket=args.s3,
                                accessKeyId=args.aws_key_id,
                                secret=args.aws_secret_key))

client.put(
    'system/plugins',
    parameters=dict(plugins=json.dumps(['jobs', 'worker', 'osumo']))
)
client.put('system/restart')

sleep(30)

client.put('system/setting',
           parameters=dict(list=json.dumps([
               dict(key='worker.broker', value=args.broker),
               dict(key='worker.backend', value=args.broker),
               dict(key='core.route_table', value=dict(
                                               core_girder="/girder",
                                               core_static_root="/static",
                                               osumo="/"))])))

client.put('system/restart')
开发者ID:osumo,项目名称:sumobot,代码行数:34,代码来源:girder-post-install.py

示例5: GirderClient

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
args = parser.parse_args()


# Get the ID for our Analyses folder.
c = GirderClient(host=args.girder_host, port=args.girder_port)
c.authenticate('girder', 'girder')
folderSearch = c.get('resource/search', parameters={
    'q': 'Analyses',
    'types': '["folder"]'
})
folderId = folderSearch['folder'][0]['_id']

# Disable authorization requirements for running romanesco tasks
c.put('system/setting', parameters={
    'key': 'flow.require_auth',
    'value': 'false'
})

# Check if these analyses already exist.  If so, we won't re-upload them.
uploadACR = False
uploadPGS = False

searchACR = c.get('resource/search', {
    'q': 'aceArbor',
    'types': '["item"]'
})
if len(searchACR['item']) == 0:
  uploadACR = True

searchPGS = c.get('resource/search', {
    'q': 'Phylogenetic signal',
开发者ID:Kitware,项目名称:flow,代码行数:33,代码来源:easymode-setup.py

示例6: main

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
def main(config):
    client = GirderClient(apiUrl=config.girder_api_url)
    client.authenticate(config.girder_user,
                        config.girder_password)

    try:
        # First run the simple flow
        print ('Running simple taskflow ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.SimpleTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

        # First run the simple flow
        print ('Running linked taskflow ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.LinkTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

        # Test terminating a simple flow
        print ('Running simple taskflow ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.SimpleTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        time.sleep(4)

        print ('Terminate the taskflow')
        url = 'taskflows/%s/terminate' % (taskflow_id)
        client.put(url)

        # Wait for it to terminate
        wait_for_terminated(client, taskflow_id)

        # Now delete it
        print ('Delete the taskflow')
        url = 'taskflows/%s' % (taskflow_id)
        try:
            client.delete(url)
        except HttpError as ex:
            if ex.status != 202:
                raise

        # Wait for it to terminate
        wait_for_deletion(client, taskflow_id)


        # Now try something with a chord
        print ('Running taskflow containing a chord ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.ChordTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

        # Now try a workflow that is the two connected together
        print ('Running taskflow that connects to parts together ...')
        taskflow_id = create_taskflow(
            client, 'cumulus.taskflow.core.test.mytaskflows.ConnectTwoTaskFlow')

        # Start the task flow
        url = 'taskflows/%s/start' % (taskflow_id)
        client.put(url)

        # Wait for it to complete
        wait_for_complete(client, taskflow_id)

#      # Now try a composite workflow approach ...
#        print ('Running taskflow that is a composite ...')
#        taskflow_id = create_taskflow(
#            client, 'cumulus.taskflow.core.test.mytaskflows.MyCompositeTaskFlow')
#
#        # Start the task flow
#        url = 'taskflows/%s/start' % (taskflow_id)
#        client.put(url)
#
#        # Wait for it to complete
#        wait_for_complete(client, taskflow_id)

    except HttpError as ex:
        print( ex.responseText)
开发者ID:Kitware,项目名称:cumulus,代码行数:101,代码来源:taskflow_runner.py

示例7: BaseIntegrationTest

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
class BaseIntegrationTest(unittest.TestCase):
    def __init__(self, name, girder_url, girder_user, girder_password, job_timeout=60, cleanup=True):
        super(BaseIntegrationTest, self).__init__(name)
        self._job_id = None
        self._script_id = None
        self._output_folder_id = None
        self._input_folder_id = None
        self._girder_url = girder_url
        self._girder_user = girder_user
        self._girder_password = girder_password
        self._job_timeout = job_timeout
        self._data = 'Need more input!'
        self._cleanup = cleanup

    def setUp(self):
        url = '%s/api/v1' % self._girder_url
        self._client = GirderClient(apiUrl=url)
        self._client.authenticate(self._girder_user,
                                  self._girder_password)

        user = self._client.get('user/me')
        self._user_id = user['_id']
        r = list(self._client.listFolder(self._user_id, 'user', name='Private'))
        self.assertEqual(len(r), 1)
        self._private_folder_id = r[0]['_id']

    def tearDown(self):

        if not self._cleanup:
            return

        if self._job_id:
            try:
                url = 'jobs/%s' % self._job_id
                self._client.delete(url)
            except Exception as e:
                traceback.print_exc()

        if self._script_id:
            try:
                url = 'scripts/%s' % self._script_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

        if self._output_folder_id:
            try:
                url = 'folder/%s' % self._output_folder_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

        if self._input_folder_id:
            try:
                url = 'folder/%s' % self._input_folder_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

    def create_script(self, commands=[
                'sleep 10', 'cat CumulusIntegrationTestInput'
            ]):
        body = {
            'commands': commands,
            'name': 'CumulusIntegrationTestLob'
        }

        r = self._client.post('scripts', data=json.dumps(body))
        self._script_id = r['_id']

    def create_input(self, folder_name='CumulusInput'):

        r = self._client.createFolder(self._private_folder_id, folder_name)
        self._input_folder_id = r['_id']
        size = len(self._data)

        item = self._client.uploadFile(self._input_folder_id,
                    StringIO(self._data), 'CumulusIntegrationTestInput', size,
                    parentType='folder')

        self._item_id = item['itemId']

    def create_output_folder(self, folder_name='CumulusOutput'):
        r = self._client.createFolder(self._private_folder_id, folder_name)
        self._output_folder_id = r['_id']

    def create_job(self, job_name='CumulusIntegrationTestJob', tail=None):
        body = {
            'name': job_name,
            'scriptId': self._script_id,
            'output': [{
              'folderId': self._output_folder_id,
              'path': '.'
            }],
            'input': [
              {
                'folderId': self._input_folder_id,
                'path': '.'
              }
            ]
#.........这里部分代码省略.........
开发者ID:Kitware,项目名称:cumulus,代码行数:103,代码来源:base_integration_test.py

示例8: find_assetstore

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
local_assetstore_name = 'local'

if find_assetstore(local_assetstore_name) is None:
    client.post('assetstore',
                parameters=dict(name=local_assetstore_name,
                                type=str(AssetstoreType.FILESYSTEM),
                                root=os.path.join(args.data_root,
                                                  'assetstores',
                                                  'local'),
                                readOnly="false"))

client.put('system/plugins',
           parameters=dict(plugins=json.dumps(['celery_jobs',
                                               'climos_test',
                                               'user_quota',
                                               'hdfs_assetstore',
                                               'jobs',
                                               'romanesco',
                                               'sparktest'])))

client.put('system/restart')

sleep(30)

client.put('system/setting',
           parameters=dict(list=json.dumps([
               dict(key='romanesco.require_auth', value=False),
               dict(key='romanesco.broker', value=args.broker),
               dict(key='romanesco.backend', value=args.broker)])))

hdfs_assetstore_name = 'hdfs'
开发者ID:Kitware,项目名称:gobig,代码行数:33,代码来源:girder-post-install.py

示例9: len

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
    collection = c.post(
        "collection", parameters={"name": "Default", "description": "Default workspace", "public": "true"}
    )
    c.post(
        "folder",
        parameters={
            "parentType": "collection",
            "parentId": collection["_id"],
            "name": "Data",
            "description": "Data Folder",
            "public": "true",
        },
    )
    c.post(
        "folder",
        parameters={
            "parentType": "collection",
            "parentId": collection["_id"],
            "name": "Analyses",
            "description": "Analysis folder",
            "public": "true",
        },
    )

# Turn on the romanesco plugin
c.put("system/plugins", parameters={"plugins": '["romanesco"]'})

# Create an assetstore if there isn't one
if len(c.get("assetstore")) == 0:
    c.post("assetstore", parameters={"type": "1", "name": "GridFS", "db": "girder-gridfs"})
开发者ID:Kitware,项目名称:flow,代码行数:32,代码来源:girder-setup.py

示例10: NewtIntegrationTest

# 需要导入模块: from girder_client import GirderClient [as 别名]
# 或者: from girder_client.GirderClient import put [as 别名]
class NewtIntegrationTest(BaseIntegrationTest):

    def __init__(self, name, girder_url, girder_user, girder_password, machine,
                 job_timeout=60*5):
        super(NewtIntegrationTest, self).__init__(name, girder_url, girder_user,
                                                  girder_password, job_timeout)
        self._cluster_id = None
        self._machine = machine

    def setUp(self):

        # First authenticate with NEWT
        self._session = Session()
        r = self._session.post('https://newt.nersc.gov/newt/auth',
                               {
                                    'username': self._girder_user,
                                    'password': self._girder_password})

        self.assertEqual(r.status_code, 200)
        print r.json()
        self._newt_session_id = r.json()['newt_sessionid']

        # Now authenticate with Girder using the session id
        url = '%s/api/v1/newt/authenticate/%s' % (self._girder_url, self._newt_session_id)
        r = self._session.put(url)
        self.assertEqual(r.status_code, 200)

        url = '%s/api/v1/newt/authenticate/%s' % (self._girder_url, self._newt_session_id)
        r = self._session.put(url)
        self.assertEqual(r.status_code, 200)

        url = '%s/api/v1' % self._girder_url
        self._client = GirderClient(apiUrl=url)
        self._client.token = self._session.cookies['girderToken']

        user = self._client.get('user/me')
        self._user_id = user['_id']
        r = self._client.listFolder(self._user_id, 'user', name='Private')
        self.assertEqual(len(r), 1)
        self._private_folder_id = r[0]['_id']

    def tearDown(self):
        super(NewtIntegrationTest, self).tearDown()
        if self._cluster_id:
            try:
                url = 'clusters/%s' % self._cluster_id
                self._client.delete(url)
            except Exception:
                traceback.print_exc()

    def create_cluster(self):
        body = {
            'config': {
                'host': self._machine
            },
            'name': 'NewtIntegrationTest',
            'type': 'newt'
        }

        r = self._client.post('clusters', data=json.dumps(body))
        self._cluster_id = r['_id']

        # Now test the connection
        r = self._client.put('clusters/%s/start' % self._cluster_id)
        sleeps = 0
        while True:
            time.sleep(1)
            r = self._client.get('clusters/%s/status' % self._cluster_id)

            if r['status'] == 'running':
                break
            elif r['status'] == 'error':
                r = self._client.get('clusters/%s/log' % self._cluster_id)
                self.fail(str(r))

            if sleeps > 9:
                self.fail('Cluster never moved into running state')
            sleeps += 1

    def assert_output(self):
        r = self._client.listItem(self._output_folder_id)
        self.assertEqual(len(r), 4)

        stdout_item = None
        for i in r:
            if i['name'].startswith('CumulusIntegrationTestJob-%s.o' % self._job_id):
                stdout_item = i
                break

        self.assertIsNotNone(stdout_item)
        r = self._client.get('item/%s/files' % i['_id'])
        self.assertEqual(len(r), 1)

        url =   '%s/api/v1/file/%s/download' % (self._girder_url, r[0]['_id'])
        r = self._session.get(url)
        self.assertEqual(r.content, self._data)


    def test(self):
        try:
#.........这里部分代码省略.........
开发者ID:mgrauer,项目名称:cumulus,代码行数:103,代码来源:newt_integration_test.py


注:本文中的girder_client.GirderClient.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。