本文整理匯總了Python中sevenbridges.meta.transformer.Transform.to_project方法的典型用法代碼示例。如果您正苦於以下問題:Python Transform.to_project方法的具體用法?Python Transform.to_project怎麽用?Python Transform.to_project使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sevenbridges.meta.transformer.Transform
的用法示例。
在下文中一共展示了Transform.to_project方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_folder
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def create_folder(cls, name, parent=None, project=None,
api=None):
"""Create a new folder
:param name: Folder name
:param parent: Parent folder
:param project: Project to create folder in
:param api: Api instance
:return: New folder
"""
api = api or cls._API
data = {
'name': name,
'type': cls.FOLDER_TYPE
}
if not parent and not project:
raise SbgError('Parent or project must be provided')
if parent and project:
raise SbgError(
'Providing both "parent" and "project" is not allowed'
)
if parent:
data['parent'] = Transform.to_file(file_=parent)
if project:
data['project'] = Transform.to_project(project=project)
response = api.post(url=cls._URL['create_folder'], data=data).json()
return cls(api=api, **response)
示例2: upload
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def upload(cls, path, project=None, parent=None, file_name=None,
overwrite=False, retry=5, timeout=10,
part_size=PartSize.UPLOAD_MINIMUM_PART_SIZE, wait=True,
api=None):
"""
Uploads a file using multipart upload and returns an upload handle
if the wait parameter is set to False. If wait is set to True it
will block until the upload is completed.
:param path: File path on local disc.
:param project: Project identifier
:param parent: Parent folder identifier
:param file_name: Optional file name.
:param overwrite: If true will overwrite the file on the server.
:param retry: Number of retries if error occurs during upload.
:param timeout: Timeout for http requests.
:param part_size: Part size in bytes.
:param wait: If true will wait for upload to complete.
:param api: Api instance.
"""
api = api or cls._API
extra = {'resource': cls.__name__, 'query': {
'path': path,
'project': project,
'file_name': file_name,
'overwrite': overwrite,
'retry': retry,
'timeout': timeout,
'part_size': part_size,
'wait': wait,
}}
logger.info('Uploading file', extra=extra)
if not project and not parent:
raise SbgError('A project or parent identifier is required.')
if project and parent:
raise SbgError(
'Project and parent identifiers are mutually exclusive.'
)
if project:
project = Transform.to_project(project)
if parent:
parent = Transform.to_file(parent)
upload = Upload(
file_path=path, project=project, parent=parent,
file_name=file_name, overwrite=overwrite, retry_count=retry,
timeout=timeout, part_size=part_size, api=api
)
if wait:
upload.start()
upload.wait()
return upload
else:
return upload
示例3: copy
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def copy(self, project, name=None):
"""
Copies the current file.
:param project: Destination project.
:param name: Destination file name.
:return: Copied File object.
"""
project = Transform.to_project(project)
data = {
'project': project
}
if name:
data['name'] = name
new_file = self._api.post(url=self._URL['copy'].format(id=self.id),
data=data).json()
return File(api=self._api, **new_file)
示例4: query
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def query(cls, project=None, visibility=None, offset=None, limit=None,
api=None):
"""
Query (List) apps.
:param visibility:
:param project:
:param offset: Pagination offset.
:param limit: Pagination limit.
:param api: Api instance.
:return: collection object
"""
if project:
project = Transform.to_project(project)
api = api or cls._API
return super(App, cls)._query(url=cls._URL['query'], project=project,
visibility=visibility,
offset=offset, limit=limit, api=api)
示例5: copy
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def copy(self, project, name=None):
"""
Copies the current app.
:param project: Destination project.
:param name: Destination app name.
:return: Copied App object.
"""
project = Transform.to_project(project)
data = {
'project': project
}
if name:
data['name'] = name
app = self._api.post(url=self._URL['copy'].format(id=self.id),
data=data).json()
return App(api=self._api, **app)
示例6: query
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def query(cls, project=None, visibility=None, q=None, id=None, offset=None,
limit=None, api=None):
"""
Query (List) apps.
:param project: Source project.
:param visibility: private|public for private or public apps.
:param q: List containing search terms.
:param id: List contains app ids. Fetch apps with specific ids.
:param offset: Pagination offset.
:param limit: Pagination limit.
:param api: Api instance.
:return: collection object
"""
if project:
project = Transform.to_project(project)
api = api or cls._API
return super(App, cls)._query(url=cls._URL['query'], project=project,
visibility=visibility, q=q, id=id,
offset=offset, limit=limit, api=api)
示例7: copy
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def copy(self, project, name=None):
"""
Copies the current file.
:param project: Destination project.
:param name: Destination file name.
:return: Copied File object.
"""
project = Transform.to_project(project)
data = {
'project': project
}
if name:
data['name'] = name
extra = {'resource': self.__class__.__name__, 'query': {
'id': self.id,
'data': data
}}
logger.info('Copying file', extra=extra)
new_file = self._api.post(url=self._URL['copy'].format(id=self.id),
data=data).json()
return File(api=self._api, **new_file)
示例8: query
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def query(cls, project, names=None, metadata=None, origin=None,
offset=None, limit=None, api=None):
"""
Query ( List ) projects
:param project: Project id
:param names: Name list
:param metadata: Metadata query dict
:param origin: Origin query dict
:param offset: Pagination offset
:param limit: Pagination limit
:param api: Api instance.
:return: Collection object.
"""
api = api or cls._API
project = Transform.to_project(project)
query_params = {}
if names and isinstance(names, list):
query_params['name'] = names
metadata_params = {}
if metadata and isinstance(metadata, dict):
for k, v in metadata.items():
metadata_params['metadata.' + k] = metadata[k]
query_params.update(metadata_params)
origin_params = {}
if origin and isinstance(origin, dict):
for k, v in origin.items():
origin_params['origin.' + k] = origin[k]
query_params.update(origin_params)
return super(File, cls)._query(api=api, url=cls._URL['query'],
project=project, offset=offset,
limit=limit, **query_params)
示例9: copy
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def copy(self, project, name=None, strategy=None):
"""
Copies the current app.
:param project: Destination project.
:param name: Destination app name.
:param strategy: App copy strategy.
:return: Copied App object.
:Copy strategies:
clone copy all revisions and continue getting updates form the
original app (default method when the key is omitted)
direct copy only the latest revision and get the updates from
this point on
clone_direct copy the app like the direct strategy, but keep all
revisions
transient copy only the latest revision and continue getting
updates from the original app
"""
strategy = strategy or AppCopyStrategy.CLONE
project = Transform.to_project(project)
data = {
'project': project,
'strategy': strategy
}
if name:
data['name'] = name
extra = {'resource': self.__class__.__name__, 'query': {
'id': self.id,
'data': data
}}
logger.info('Copying app', extra=extra)
app = self._api.post(url=self._URL['copy'].format(id=self.id),
data=data).json()
return App(api=self._api, **app)
示例10: create
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def create(cls, name, project, app, batch_input=None, batch_by=None,
inputs=None,
description=None, run=False, api=None):
"""
Creates a task on server.
:param name: Task name.
:param project: Project identifier.
:param app: CWL app identifier.
:param batch_input: Batch input.
:param batch_by: Batch criteria.
:param inputs: Input map.
:param description: Task description.
:param run: True if you want to run a task upon creation.
:param api: Api instance.
:return: Task object.
"""
task_data = {}
project = Transform.to_project(project)
app = Transform.to_app(app)
task_inputs = {'inputs': {}}
for k, v in inputs.items():
if isinstance(v, File):
input = {
'class': 'File',
'path': v.id,
}
task_inputs['inputs'][k] = input
elif isinstance(v, list):
input_list = []
for inp in v:
if isinstance(inp, File):
input = {
'class': 'File',
'path': inp.id,
}
if inp.name:
input['name'] = inp.name
input_list.append(input)
else:
input_list.append(inp)
task_inputs['inputs'][k] = input_list
else:
task_inputs['inputs'][k] = v
if batch_input:
task_data['batch_input'] = batch_input
if batch_by:
task_data['batch_by'] = batch_by
task_meta = {
'name': name,
'project': project,
'app': app,
'description': description
}
task_data.update(task_meta)
task_data.update(task_inputs)
params = {'action': 'run'} if run else {}
api = api if api else cls._API
created_task = api.post(cls._URL['query'], data=task_data,
params=params).json()
return Task(api=api, **created_task)
示例11: test_transform_project_invalid_values
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def test_transform_project_invalid_values(project):
with pytest.raises(SbgError):
Transform.to_project(project)
示例12: test_transform_project
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def test_transform_project(project):
Transform.to_project(project)
示例13: query
# 需要導入模塊: from sevenbridges.meta.transformer import Transform [as 別名]
# 或者: from sevenbridges.meta.transformer.Transform import to_project [as 別名]
def query(cls, project=None, names=None, metadata=None, origin=None,
tags=None, offset=None, limit=None, dataset=None, api=None,
parent=None):
"""
Query ( List ) files, requires project or dataset
:param project: Project id
:param names: Name list
:param metadata: Metadata query dict
:param origin: Origin query dict
:param tags: List of tags to filter on
:param offset: Pagination offset
:param limit: Pagination limit
:param dataset: Dataset id
:param api: Api instance.
:param parent: Folder id or File object with type folder
:return: Collection object.
"""
api = api or cls._API
query_params = {}
if project:
project = Transform.to_project(project)
query_params['project'] = project
if dataset:
dataset = Transform.to_dataset(dataset)
query_params['dataset'] = dataset
if parent:
query_params['parent'] = Transform.to_file(parent)
if not (project or dataset or parent):
raise SbgError('Project, dataset or parent must be provided.')
if [project, parent, dataset].count(None) < 2:
raise SbgError(
'Only one out of project, parent or dataset must be provided.'
)
if names is not None and isinstance(names, list):
if len(names) == 0:
names.append("")
query_params['name'] = names
metadata_params = {}
if metadata and isinstance(metadata, dict):
for k, v in metadata.items():
metadata_params['metadata.' + k] = metadata[k]
if tags:
query_params['tag'] = tags
query_params.update(metadata_params)
origin_params = {}
if origin and isinstance(origin, dict):
for k, v in origin.items():
origin_params['origin.' + k] = origin[k]
query_params.update(origin_params)
return super(File, cls)._query(
api=api, url=cls._URL['query'], offset=offset,
limit=limit, fields='_all', **query_params
)