!12054 fix: enhance init cache cmd by entrance script

From: @jonyguo
Reviewed-by: @pandoublefeng,@liucunwei
Signed-off-by: @pandoublefeng
This commit is contained in:
mindspore-ci-bot 2021-02-04 09:13:23 +08:00 committed by Gitee
commit 6b39c89da7
2 changed files with 39 additions and 19 deletions

View File

@ -0,0 +1,33 @@
# Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed 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.
# ==============================================================================
"""
This is the entrance to start the cache service
"""
import os
import stat
import sys
import mindspore
def main():
"""Entry point for cache service"""
cache_admin_dir = os.path.join(os.path.dirname(mindspore.__file__), "bin")
os.chdir(cache_admin_dir)
cache_admin = os.path.join(cache_admin_dir, "cache_admin")
cache_server = os.path.join(cache_admin_dir, "cache_server")
os.chmod(cache_admin, stat.S_IRWXU)
os.chmod(cache_server, stat.S_IRWXU)
cmd = cache_admin + " " + " ".join(sys.argv[1:])
os.system(cmd)

View File

@ -129,6 +129,7 @@ package_data = {
'*.so*',
'*.pyd',
'*.dll',
'bin/*',
'lib/*.so*',
'lib/*.a',
'lib/*.dylib*',
@ -161,24 +162,6 @@ def update_permissions(path):
file_fullpath = os.path.join(dirpath, filename)
os.chmod(file_fullpath, stat.S_IREAD)
def bin_files():
"""
Gets the binary files to be installed.
"""
data_files = []
binary_files = []
cache_server_bin = os.path.join('mindspore', 'bin', 'cache_server')
if not os.path.exists(cache_server_bin):
return data_files
binary_files.append(cache_server_bin)
cache_admin_bin = os.path.join('mindspore', 'bin', 'cache_admin')
if not os.path.exists(cache_admin_bin):
return data_files
binary_files.append(cache_admin_bin)
data_files.append(('bin', binary_files))
return data_files
class EggInfo(egg_info):
"""Egg info."""
@ -215,7 +198,6 @@ setup(
'framework that could be used for mobile, edge and cloud scenarios.',
long_description="\n\n".join([readme, release]),
long_description_content_type="text/markdown",
data_files=bin_files(),
packages=find_packages(),
package_data=package_data,
include_package_data=True,
@ -223,6 +205,11 @@ setup(
'egg_info': EggInfo,
'build_py': BuildPy,
},
entry_points={
'console_scripts': [
'cache_admin=mindspore.dataset.engine.cache_admin:main',
],
},
python_requires='>=3.7',
install_requires=required_package,
classifiers=[