Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 对环境判断以处理开发环境由于配置文件路径不存在导致的异常 #225

Merged
merged 5 commits into from Jun 21, 2023

Conversation

ljtnono
Copy link
Contributor

@ljtnono ljtnono commented Jun 21, 2023

Fix #224

@netlify
Copy link

netlify bot commented Jun 21, 2023

Deploy Preview for kubespider ready!

Name Link
🔨 Latest commit 31f32f2
🔍 Latest deploy log https://app.netlify.com/sites/kubespider/deploys/64931e051305c300085efcda
😎 Deploy Preview https://deploy-preview-225--kubespider.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@richardli1598 richardli1598 changed the title 对环境判断以处理开发环境由于配置文件路径不存在导致的异常 fix: 对环境判断以处理开发环境由于配置文件路径不存在导致的异常 Jun 21, 2023
@richardli1598
Copy link
Contributor

hello, 感谢大佬的PR, 可以修复一下ci报的问题吗

@ljtnono
Copy link
Contributor Author

ljtnono commented Jun 21, 2023

hello, 感谢大佬的PR, 可以修复一下ci报的问题吗

好的,我看看

@ljtnono
Copy link
Contributor Author

ljtnono commented Jun 21, 2023

hello, 感谢大佬的PR, 可以修复一下ci报的问题吗

好像是因为循环依赖导致的问题,python这个好奇怪,循环依赖在调试环境不会报错。

已经重新提交了。

kubespider/utils/helper.py Outdated Show resolved Hide resolved
kubespider/utils/helper.py Outdated Show resolved Hide resolved
kubespider/core/config_handler.py Outdated Show resolved Hide resolved
if not is_running_in_docker():
if not os.path.exists(values.CFG_BASE_PATH):
os.makedirs(values.CFG_BASE_PATH)
values.CFG_TEMPLATE_PATH = os.path.join(os.path.dirname(os.getcwd()), '.config/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> os.path.join(os.path.dirname(os.getcwd()), '.config/')
'/Users/.config/'
>>> ^D
richardli1598@richardli1598 [~]
-> % pwd
/Users/richardli1598

这个是预期行为吗?是不是至少应该是 /Users/richardli1598/.config? 那么是不是如下代码更合适:

>>> os.path.join(os.getcwd(), '.config/')
'/Users/richardli1598/.config/'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是预期行为吧,这里源代码结构一般clone下来是有两层kubespider目录吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

例如:代码clone下来在/Users/ljt/code/kubespider 目录下,那么os.getcwd()应该是/Users/ljt/code/kubespider/kubespider,那么os.path.dirname(os.getcwd())就是/Users/ljt/code/kubespider,即代码根目录,join上.config 就是默认配置模板目录

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,感谢解释。
这里麻烦加点注释,说明一下,运行时,需要在 {repo_root}/kubespider/kubespider 下面运行,其他地方运行可能不行

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释和校验容器运行方式按照你说的格式改了,然后我看了下,ci报错好像不是我那段代码报错,我pr里面有个pylint 的style错误,好像是多加了一行空格,这个我也改了。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,这个导入为啥总失败啊,我本地运行都可以。python真的太神奇了

这个应该如下修改就行:

-from kubespider.utils import helper
+from utils import helper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,这个导入为啥总失败啊,我本地运行都可以。python真的太神奇了

这个应该如下修改就行:

-from kubespider.utils import helper
+from utils import helper

嗯这个我修改了,但是我看这个pylint还有导入包顺序限制?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯,现在ok了,一般顺序是 系统,第三方,本项目库

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯,现在ok了

额,开源新手,github这些流程还不太会。麻烦你了

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

欢迎下次贡献,一起共建!

@@ -16,6 +16,7 @@
from api.values import Config
from api import values
from utils.config_reader import YamlFileSectionConfigReader, YamlFileConfigReader
from kubespider.utils import helper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-from kubespider.utils import helper
+from utils import helper

@richardli1598
Copy link
Contributor

member邀请以发出,请查收:https://github.com/settings/organizations

@richardli1598 richardli1598 merged commit 54479a1 into opennaslab:main Jun 21, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

调试环境读取配置文件失败
2 participants