服务器设置 (.settings)#
预计阅读时间:5分钟
你将学习的内容#
本指南旨在帮助您学习如何配置Datasite服务器的配置文件。
服务器设置#
服务器简介(或元数据)对于欢迎研究人员加入您的服务器非常重要,这样他们可以轻松了解谁在支持该服务器、所属组织以及可以在服务器上找到什么内容
# Launching a simple server
import syft as sy
server = sy.orchestra.launch(
name="my_special_server",
reset=True,
dev_mode=False,
port="auto",
)
要将您的服务器配置为数据所有者,可以从查看服务器设置开始:
client = sy.login(url="localhost", port=server.port, email="[email protected]", password="changethis")
client.settings
该领域的可用设置如下:
自助注册#
该设置可通过client.settings.allow_guest_signup()进行配置,允许管理员开启或关闭自助注册功能。这样,访客用户只要知道您服务器的托管地址(例如公共IP),就可以自行在您的服务器上注册。此功能非常适合低安全级别的服务器,但对于高安全级别的服务器需谨慎使用。
通知#
通过设置,管理员还可以配置服务器是否应向用户发送通知。此功能仅在SMTP服务已配置的情况下才能启用,通过client.settings.enable_notifications()启用,通过client.settings.disable_notifications()禁用。了解更多信息请点击这里。
关联#
您的服务器只有在与其他服务器建立关联后,才能被其他对等服务器或网关服务器发现。这意味着两台服务器之间存在路由连接,可以根据需要进行通信。为此,必须由其中一方创建关联请求。关于如何更好地使用PySyft网络功能的更多文档即将发布。
可用设置association_request_auto_approval表示您将自动批准此类请求。这对于低安全级别的服务器是理想选择,但对于高安全级别的服务器请谨慎操作。
服务器配置文件#
为外部研究人员设置服务器可见信息非常重要。
让我们看看当前默认服务器上设置了哪些信息:
dict(client.metadata)
假设我们希望更新这些信息点以更好地反映服务器状态,可以通过ServerSettingsUpdate来实现,它允许用户修改:
name: str: 服务器名称organization: str: 他们所在组织的名称description: str: 服务器及其用途的描述admin_email: str: 管理员用户的电子邮件,数据科学家可以用来联系signup_enabled: bool: 是否允许自助注册association_request_auto_approval: bool: 是否允许自动批准关联请求
from syft.service.settings.settings import ServerSettingsUpdate
new_settings = ServerSettingsUpdate(
server_side_type="low",
organization="Green Org",
name="my_very_special_server",
description="This is the low side server of the Green Organisation.")
client.settings.update(settings=new_settings)
# Requires re-logining in to fetch the updates
client = sy.login(url="localhost", port=server.port, email="[email protected]", password="changethis")
client
自定义欢迎消息#
It would be very useful for data scientists to learn as much about your server as soon as they log in. PySyft allows you to customize the welcome message shown upon login with anything HTML or Markdown.
为了便于开发自定义智能体,PySyft提供了一些实用工具来帮助你:
client.settings.welcome_preview(markdown/html="..")to preview how your intended welcome message is rendered in your execution environment (e.g Jupyter Notebook)client.settings.welcome_customize(markdown/html="..")to set a new version of the welcome messageclient.settings.welcome_show()用于检查更改是否成功
让我们看看如何通过添加描述来扩展当前消息。
# Expanding the default message
previous_welcome = client.settings.welcome_show()
previous_welcome
让我们从当前样式开始构建一个。我们将沿用相同的样式,但修改图像、URL和展示的信息。要复制这些样式,我们可以访问client.settings.welcome_show().text:
Show code cell source
new_welcome ="""
<style>
/* cyrillic-ext */
@font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSKmu0SC55K5gw.woff2) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
/* cyrillic */ @font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSumu0SC55K5gw.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
/* greek-ext */ @font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSOmu0SC55K5gw.woff2) format("woff2"); unicode-range: U+1F00-1FFF; }
/* greek */ @font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSymu0SC55K5gw.woff2) format("woff2"); unicode-range: U+0370-03FF; }
/* hebrew */ @font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS2mu0SC55K5gw.woff2) format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
/* vietnamese */ @font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSCmu0SC55K5gw.woff2) format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
/* latin-ext */ @font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSGmu0SC55K5gw.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
/* latin */ @font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-stretch: 100%; src: url(https://fonts.gstatic.com/s/opensans/v35/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS-mu0SC55I.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
.syft-container {
padding: 5px;
font-family: 'Open Sans';
}
.syft-alert-info {
color: #1F567A;
background-color: #C2DEF0;
border-radius: 4px;
padding: 5px;
padding: 13px 10px
}
.syft-code-block {
background-color: #f7f7f7;
border: 1px solid #cfcfcf;
padding: 0px 2px;
}
.syft-space {
margin-top: 1em;
}
</style>
<div class="syft-client syft-container">
<img src="https://emojiisland.com/cdn/shop/products/Smiling_Emoji_Icon_-_Blushed_large.png?v=1571606114" alt="Logo"
style="width:48px;height:48px;padding:3px;">
<h2>Welcome to Red Organisation</h2>
<div class="syft-space">
<strong>URL:</strong> https://datasite.red_organisation.org<br />
<strong>Server Type:</strong> Domain <br />
<strong>Server Side Type:</strong>High Side<br />
<strong>Syft Version:</strong> 0.8.7-beta.10<br />
</div>
<div>
<h3>About my_special_server</h3>
<p> This server is open to all researchers interested in conducting studies about climate change and its implications on the biodiveristy using Red Organisation's data.
</div>
</div><br />
"""
client.settings.welcome_preview(html=new_welcome)
client.settings.welcome_customize(html=new_welcome)
client.settings.welcome_show()
现在,您的Datasite服务器应该已经准备就绪,可以进一步配置并供数据科学家使用了!