Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
DolphinScheduler
提交
59cd8615
DolphinScheduler
项目概览
apache
/
DolphinScheduler
上一次同步 接近 2 年
通知
707
Star
9572
Fork
3514
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
59cd8615
编写于
7月 12, 2022
作者:
陈
陈家名
提交者:
GitHub
7月 12, 2022
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Python] Supports creating or editing resources. (#10823)
上级
499e5b13
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
318 addition
and
2 deletion
+318
-2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
...org/apache/dolphinscheduler/api/python/PythonGateway.java
+15
-0
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
...apache/dolphinscheduler/api/service/ResourcesService.java
+24
-0
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
...lphinscheduler/api/service/impl/ResourcesServiceImpl.java
+92
-0
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
...apache/dolphinscheduler/api/python/PythonGatewayTest.java
+20
-0
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
...he/dolphinscheduler/api/service/ResourcesServiceTest.java
+59
-1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
...in/java/org/apache/dolphinscheduler/common/Constants.java
+5
-0
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/process_definition.py
...heduler/src/pydolphinscheduler/core/process_definition.py
+14
-0
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/resource.py
...ydolphinscheduler/src/pydolphinscheduler/core/resource.py
+43
-0
dolphinscheduler-python/pydolphinscheduler/tests/core/test_process_definition.py
.../pydolphinscheduler/tests/core/test_process_definition.py
+8
-1
dolphinscheduler-python/pydolphinscheduler/tests/core/test_resource_definition.py
...pydolphinscheduler/tests/core/test_resource_definition.py
+38
-0
未找到文件。
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
浏览文件 @
59cd8615
...
...
@@ -547,6 +547,21 @@ public class PythonGateway {
return
result
;
}
/**
* create or update resource.
* If the folder is not already created, it will be
*
* @param userName user who create or update resource
* @param fullName The fullname of resource.Includes path and suffix.
* @param description description of resource
* @param resourceContent content of resource
* @return id of resource
*/
public
Integer
createOrUpdateResource
(
String
userName
,
String
fullName
,
String
description
,
String
resourceContent
)
{
return
resourceService
.
createOrUpdateResource
(
userName
,
fullName
,
description
,
resourceContent
);
}
@PostConstruct
public
void
init
()
{
if
(
pythonGatewayConfiguration
.
getEnabled
())
{
...
...
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
浏览文件 @
59cd8615
...
...
@@ -168,6 +168,30 @@ public interface ResourcesService {
*/
Result
<
Object
>
onlineCreateResource
(
User
loginUser
,
ResourceType
type
,
String
fileName
,
String
fileSuffix
,
String
desc
,
String
content
,
int
pid
,
String
currentDirectory
);
/**
* create or update resource.
* If the folder is not already created, it will be
*
* @param loginUser user who create or update resource
* @param fileFullName The full name of resource.Includes path and suffix.
* @param desc description of resource
* @param content content of resource
* @return create result code
*/
Result
<
Object
>
onlineCreateOrUpdateResourceWithDir
(
User
loginUser
,
String
fileFullName
,
String
desc
,
String
content
);
/**
* create or update resource.
* If the folder is not already created, it will be
*
* @param userName user who create or update resource
* @param fullName The fullname of resource.Includes path and suffix.
* @param description description of resource
* @param resourceContent content of resource
* @return id of resource
*/
Integer
createOrUpdateResource
(
String
userName
,
String
fullName
,
String
description
,
String
resourceContent
);
/**
* updateProcessInstance resource
*
...
...
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
浏览文件 @
59cd8615
...
...
@@ -85,10 +85,12 @@ import java.util.stream.Collectors;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
ALIAS
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
CONTENT
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
EMPTY_STRING
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
FOLDER_SEPARATOR
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
FORMAT_SS
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
FORMAT_S_S
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
JAR
;
import
static
org
.
apache
.
dolphinscheduler
.
common
.
Constants
.
PERIOD
;
/**
* resources service impl
...
...
@@ -1117,6 +1119,96 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
return
result
;
}
/**
* create or update resource.
* If the folder is not already created, it will be
*
* @param loginUser user who create or update resource
* @param fileFullName The full name of resource.Includes path and suffix.
* @param desc description of resource
* @param content content of resource
* @return create result code
*/
@Override
@Transactional
public
Result
<
Object
>
onlineCreateOrUpdateResourceWithDir
(
User
loginUser
,
String
fileFullName
,
String
desc
,
String
content
)
{
if
(
checkResourceExists
(
fileFullName
,
ResourceType
.
FILE
.
ordinal
()))
{
Resource
resource
=
resourcesMapper
.
queryResource
(
fileFullName
,
ResourceType
.
FILE
.
ordinal
()).
get
(
0
);
Result
<
Object
>
result
=
this
.
updateResourceContent
(
loginUser
,
resource
.
getId
(),
content
);
if
(
result
.
getCode
()
==
Status
.
SUCCESS
.
getCode
())
{
resource
.
setDescription
(
desc
);
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
new
BeanMap
(
resource
).
entrySet
())
{
if
(!
Constants
.
CLASS
.
equalsIgnoreCase
(
entry
.
getKey
().
toString
()))
{
resultMap
.
put
(
entry
.
getKey
().
toString
(),
entry
.
getValue
());
}
}
result
.
setData
(
resultMap
);
}
return
result
;
}
else
{
String
resourceSuffix
=
fileFullName
.
substring
(
fileFullName
.
indexOf
(
PERIOD
)
+
1
);
String
fileNameWithSuffix
=
fileFullName
.
substring
(
fileFullName
.
lastIndexOf
(
FOLDER_SEPARATOR
)
+
1
);
String
resourceDir
=
fileFullName
.
replace
(
fileNameWithSuffix
,
EMPTY_STRING
);
String
resourceName
=
fileNameWithSuffix
.
replace
(
PERIOD
+
resourceSuffix
,
EMPTY_STRING
);
String
[]
dirNames
=
resourceDir
.
split
(
FOLDER_SEPARATOR
);
int
pid
=
-
1
;
StringBuilder
currDirPath
=
new
StringBuilder
();
for
(
String
dirName
:
dirNames
)
{
if
(
StringUtils
.
isNotEmpty
(
dirName
))
{
pid
=
queryOrCreateDirId
(
loginUser
,
pid
,
currDirPath
.
toString
(),
dirName
);
currDirPath
.
append
(
FOLDER_SEPARATOR
).
append
(
dirName
);
}
}
return
this
.
onlineCreateResource
(
loginUser
,
ResourceType
.
FILE
,
resourceName
,
resourceSuffix
,
desc
,
content
,
pid
,
currDirPath
.
toString
());
}
}
@Override
@Transactional
public
Integer
createOrUpdateResource
(
String
userName
,
String
fullName
,
String
description
,
String
resourceContent
)
{
User
user
=
userMapper
.
queryByUserNameAccurately
(
userName
);
int
suffixLabelIndex
=
fullName
.
indexOf
(
PERIOD
);
if
(
suffixLabelIndex
==
-
1
)
{
String
msg
=
String
.
format
(
"The suffix of file can not be empty : %s"
,
fullName
);
logger
.
error
(
msg
);
throw
new
IllegalArgumentException
(
msg
);
}
if
(!
fullName
.
startsWith
(
FOLDER_SEPARATOR
))
{
fullName
=
FOLDER_SEPARATOR
+
fullName
;
}
Result
<
Object
>
createResult
=
onlineCreateOrUpdateResourceWithDir
(
user
,
fullName
,
description
,
resourceContent
);
if
(
createResult
.
getCode
()
==
Status
.
SUCCESS
.
getCode
())
{
Map
<
String
,
Object
>
resultMap
=
(
Map
<
String
,
Object
>)
createResult
.
getData
();
return
(
int
)
resultMap
.
get
(
"id"
);
}
String
msg
=
String
.
format
(
"Can not create or update resource : %s"
,
fullName
);
logger
.
error
(
msg
);
throw
new
IllegalArgumentException
(
msg
);
}
private
int
queryOrCreateDirId
(
User
user
,
int
pid
,
String
currentDir
,
String
dirName
)
{
String
dirFullName
=
currentDir
+
FOLDER_SEPARATOR
+
dirName
;
if
(
checkResourceExists
(
dirFullName
,
ResourceType
.
FILE
.
ordinal
()))
{
List
<
Resource
>
resourceList
=
resourcesMapper
.
queryResource
(
dirFullName
,
ResourceType
.
FILE
.
ordinal
());
return
resourceList
.
get
(
0
).
getId
();
}
else
{
// create dir
Result
<
Object
>
createDirResult
=
this
.
createDirectory
(
user
,
dirName
,
EMPTY_STRING
,
ResourceType
.
FILE
,
pid
,
currentDir
);
if
(
createDirResult
.
getCode
()
==
Status
.
SUCCESS
.
getCode
())
{
Map
<
String
,
Object
>
resultMap
=
(
Map
<
String
,
Object
>)
createDirResult
.
getData
();
return
(
int
)
resultMap
.
get
(
"id"
);
}
else
{
String
msg
=
String
.
format
(
"Can not create dir %s"
,
dirFullName
);
logger
.
error
(
msg
);
throw
new
IllegalArgumentException
(
msg
);
}
}
}
private
void
permissionPostHandle
(
ResourceType
resourceType
,
User
loginUser
,
Integer
resourceId
)
{
AuthorizationType
authorizationType
=
resourceType
.
equals
(
ResourceType
.
FILE
)
?
AuthorizationType
.
RESOURCE_FILE_ID
:
AuthorizationType
.
UDF_FILE
;
permissionPostHandle
(
authorizationType
,
loginUser
.
getId
(),
Collections
.
singletonList
(
resourceId
),
logger
);
...
...
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
浏览文件 @
59cd8615
...
...
@@ -96,6 +96,26 @@ public class PythonGatewayTest {
Assert
.
assertEquals
((
long
)
result
.
get
(
"taskDefinitionCode"
),
taskDefinition
.
getCode
());
}
@Test
public
void
testCreateResource
()
{
User
user
=
getTestUser
();
String
resourceDir
=
"/dir1/dir2/"
;
String
resourceName
=
"test"
;
String
resourceSuffix
=
"py"
;
String
desc
=
"desc"
;
String
content
=
"content"
;
String
resourceFullName
=
resourceDir
+
resourceName
+
"."
+
resourceSuffix
;
int
resourceId
=
3
;
Mockito
.
when
(
resourcesService
.
createOrUpdateResource
(
user
.
getUserName
(),
resourceFullName
,
desc
,
content
))
.
thenReturn
(
resourceId
);
int
id
=
pythonGateway
.
createOrUpdateResource
(
user
.
getUserName
(),
resourceFullName
,
desc
,
content
);
Assert
.
assertEquals
(
id
,
resourceId
);
}
@Test
public
void
testQueryResourcesFileInfo
()
{
...
...
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
浏览文件 @
59cd8615
...
...
@@ -605,6 +605,64 @@ public class ResourcesServiceTest {
}
@Test
public
void
testOnlineCreateResourceWithDir
()
{
User
user
=
getUser
();
user
.
setId
(
1
);
String
dir1Path
=
"/dir1"
;
String
dir2Path
=
"/dir2"
;
String
resourceDir
=
dir1Path
+
dir2Path
;
String
resourceName
=
"test"
;
String
resourceSuffix
=
"py"
;
String
desc
=
"desc"
;
String
content
=
"content"
;
String
fullName
=
resourceDir
+
"/"
+
resourceName
+
"."
+
resourceSuffix
;
Resource
dir1
=
new
Resource
();
dir1
.
setFullName
(
dir1Path
);
dir1
.
setId
(
1
);
dir1
.
setUserId
(
user
.
getId
());
Resource
dir2
=
new
Resource
();
dir2
.
setFullName
(
resourceDir
);
dir2
.
setUserId
(
user
.
getId
());
Mockito
.
when
(
resourcesMapper
.
queryResource
(
dir1
.
getFullName
(),
ResourceType
.
FILE
.
ordinal
())).
thenReturn
(
Collections
.
singletonList
(
dir1
));
Mockito
.
when
(
resourcesMapper
.
queryResource
(
resourceDir
,
ResourceType
.
FILE
.
ordinal
())).
thenReturn
(
null
);
PowerMockito
.
when
(
resourcePermissionCheckService
.
operationPermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
1
,
ApiFuncIdentificationConstant
.
FILE_VIEW
,
serviceLogger
)).
thenReturn
(
true
);
PowerMockito
.
when
(
resourcePermissionCheckService
.
resourcePermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
new
Object
[]{
dir1
.
getId
()},
1
,
serviceLogger
)).
thenReturn
(
true
);
Tenant
tenant
=
getTenant
();
PowerMockito
.
when
(
resourcePermissionCheckService
.
operationPermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
1
,
ApiFuncIdentificationConstant
.
FOLDER_ONLINE_CREATE
,
serviceLogger
)).
thenReturn
(
true
);
PowerMockito
.
when
(
resourcePermissionCheckService
.
resourcePermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
null
,
1
,
serviceLogger
)).
thenReturn
(
true
);
try
{
PowerMockito
.
when
(
storageOperate
.
mkdir
(
tenant
.
getTenantCode
(),
null
)).
thenReturn
(
true
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"storage error"
,
e
);
}
PowerMockito
.
when
(
resourcePermissionCheckService
.
operationPermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
1
,
ApiFuncIdentificationConstant
.
FILE_ONLINE_CREATE
,
serviceLogger
)).
thenReturn
(
true
);
PowerMockito
.
when
(
resourcePermissionCheckService
.
resourcePermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
null
,
1
,
serviceLogger
)).
thenReturn
(
true
);
PowerMockito
.
when
(
PropertyUtils
.
getResUploadStartupState
()).
thenReturn
(
true
);
PowerMockito
.
when
(
resourcePermissionCheckService
.
operationPermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
1
,
ApiFuncIdentificationConstant
.
FILE_RENAME
,
serviceLogger
)).
thenReturn
(
true
);
PowerMockito
.
when
(
resourcePermissionCheckService
.
resourcePermissionCheck
(
AuthorizationType
.
RESOURCE_FILE_ID
,
null
,
1
,
serviceLogger
)).
thenReturn
(
true
);
Mockito
.
when
(
tenantMapper
.
queryById
(
1
)).
thenReturn
(
getTenant
());
Mockito
.
when
(
resourcesMapper
.
selectById
(
dir1
.
getId
())).
thenReturn
(
dir1
);
Mockito
.
when
(
resourcesMapper
.
selectById
(
dir2
.
getId
())).
thenReturn
(
dir2
);
Mockito
.
when
(
FileUtils
.
getUploadFilename
(
Mockito
.
anyString
(),
Mockito
.
anyString
())).
thenReturn
(
"test"
);
PowerMockito
.
when
(
FileUtils
.
writeContent2File
(
Mockito
.
anyString
(),
Mockito
.
anyString
())).
thenReturn
(
true
);
Result
<
Object
>
result
=
resourcesService
.
onlineCreateOrUpdateResourceWithDir
(
user
,
fullName
,
desc
,
content
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getMsg
(),
result
.
getMsg
());
}
@Test
public
void
testUpdateResourceContent
()
{
PowerMockito
.
when
(
PropertyUtils
.
getResUploadStartupState
()).
thenReturn
(
false
);
...
...
@@ -896,7 +954,7 @@ public class ResourcesServiceTest {
return
resource
;
}
private
Resource
getResource
(
int
resourceId
,
ResourceType
type
)
{
private
Resource
getResource
(
int
resourceId
,
ResourceType
type
)
{
Resource
resource
=
new
Resource
();
resource
.
setId
(
resourceId
);
...
...
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
浏览文件 @
59cd8615
...
...
@@ -159,6 +159,11 @@ public final class Constants {
*/
public
static
final
String
COLON
=
":"
;
/**
* period .
*/
public
static
final
String
PERIOD
=
"."
;
/**
* QUESTION ?
*/
...
...
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/process_definition.py
浏览文件 @
59cd8615
...
...
@@ -63,6 +63,9 @@ class ProcessDefinition(Base):
thought Web UI after it :func:`submit` or :func:`run`. It will create a new project belongs to
``user`` if it does not exists. And when ``project`` exists but project's create do not belongs
to ``user``, will grant `project` to ``user`` automatically.
:param resource_list: Resource files required by the current process definition.You can create and modify
resource files from this field. When the process definition is submitted, these resource files are also
submitted along with it.
"""
# key attribute for identify ProcessDefinition object
...
...
@@ -88,6 +91,7 @@ class ProcessDefinition(Base):
"tasks"
,
"task_definition_json"
,
"task_relation_json"
,
"resource_list"
,
}
def
__init__
(
...
...
@@ -107,6 +111,7 @@ class ProcessDefinition(Base):
timeout
:
Optional
[
int
]
=
0
,
release_state
:
Optional
[
str
]
=
configuration
.
WORKFLOW_RELEASE_STATE
,
param
:
Optional
[
Dict
]
=
None
,
resource_list
:
Optional
[
List
]
=
None
,
):
super
().
__init__
(
name
,
description
)
self
.
schedule
=
schedule
...
...
@@ -132,6 +137,7 @@ class ProcessDefinition(Base):
# TODO how to fix circle import
self
.
_task_relations
:
set
[
"TaskRelation"
]
=
set
()
# noqa: F821
self
.
_process_definition_code
=
None
self
.
resource_list
=
resource_list
or
[]
def
__enter__
(
self
)
->
"ProcessDefinition"
:
ProcessDefinitionContext
.
set
(
self
)
...
...
@@ -407,6 +413,14 @@ class ProcessDefinition(Base):
None
,
None
,
)
if
len
(
self
.
resource_list
)
>
0
:
for
res
in
self
.
resource_list
:
gateway
.
entry_point
.
createOrUpdateResource
(
self
.
_user
,
res
.
name
,
res
.
description
,
res
.
content
,
)
return
self
.
_process_definition_code
def
start
(
self
)
->
None
:
...
...
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/resource.py
0 → 100644
浏览文件 @
59cd8615
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Module resource."""
from
typing
import
Optional
from
pydolphinscheduler.core.base
import
Base
class
Resource
(
Base
):
"""resource object, will define the resources that you want to create or update.
:param name: The fullname of resource.Includes path and suffix.
:param content: The description of resource.
:param description: The description of resource.
"""
_DEFINE_ATTR
=
{
"name"
,
"content"
,
"description"
}
def
__init__
(
self
,
name
:
str
,
content
:
str
,
description
:
Optional
[
str
]
=
None
,
):
super
().
__init__
(
name
,
description
)
self
.
content
=
content
self
.
_resource_code
=
None
dolphinscheduler-python/pydolphinscheduler/tests/core/test_process_definition.py
浏览文件 @
59cd8615
...
...
@@ -18,7 +18,7 @@
"""Test process definition."""
from
datetime
import
datetime
from
typing
import
Any
from
typing
import
Any
,
List
from
unittest.mock
import
patch
import
pytest
...
...
@@ -26,6 +26,7 @@ from freezegun import freeze_time
from
pydolphinscheduler.core
import
configuration
from
pydolphinscheduler.core.process_definition
import
ProcessDefinition
from
pydolphinscheduler.core.resource
import
Resource
from
pydolphinscheduler.exceptions
import
PyDSParamException
from
pydolphinscheduler.side
import
Project
,
Tenant
,
User
from
pydolphinscheduler.tasks.switch
import
Branch
,
Default
,
Switch
,
SwitchCondition
...
...
@@ -90,6 +91,11 @@ def test_process_definition_default_value(name, value):
(
"warning_group_id"
,
int
,
1
),
(
"timeout"
,
int
,
1
),
(
"param"
,
dict
,
{
"key"
:
"value"
}),
(
"resource_list"
,
List
,
[
Resource
(
name
=
"/dev/test.py"
,
content
=
"hello world"
,
description
=
"desc"
)],
),
],
)
def
test_set_attr
(
name
,
cls
,
expect
):
...
...
@@ -321,6 +327,7 @@ def test_process_definition_get_define_without_task():
"tasks"
:
{},
"taskDefinitionJson"
:
[{}],
"taskRelationJson"
:
[{}],
"resourceList"
:
[],
}
with
ProcessDefinition
(
TEST_PROCESS_DEFINITION_NAME
)
as
pd
:
assert
pd
.
get_define
()
==
expect
...
...
dolphinscheduler-python/pydolphinscheduler/tests/core/test_resource_definition.py
0 → 100644
浏览文件 @
59cd8615
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Test resource definition."""
from
pydolphinscheduler.core.resource
import
Resource
def
test_resource
():
"""Test resource set attributes which get with same type."""
name
=
"/dev/test.py"
content
=
"""print("hello world")"""
description
=
"hello world"
expect
=
{
"name"
:
name
,
"content"
:
content
,
"description"
:
description
,
}
resourceDefinition
=
Resource
(
name
=
name
,
content
=
content
,
description
=
description
,
)
assert
resourceDefinition
.
get_define
()
==
expect
GitCode官方
@csdn_codechina
mentioned in commit
4da1240b
·
9月 10, 2022
mentioned in commit
4da1240b
mentioned in commit 4da1240b0e1405533708b8b2a1921be6fd2d3bc6
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录