当前位置: 首页 > 软件库 > 神经网络/人工智能 > >

scriptedforms

授权协议 Apache-2.0 License
开发语言 Python
所属分类 神经网络/人工智能
软件类型 开源软件
地区 不详
投 递 者 呼延才
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Scripted Forms

Project Archived

This project has been archived. It was aiming to achieve similar aims to projects such asStreamlit.Streamlit is building a valuable community and support. I recommend using it over ScriptedForms.

Overview

Making GUIs easy for everyone on your team.

The primary benefit is that front ends for Python code become easily accessibleto everyone on your team. Easy to use, easy to update, easy to extend, and easyto understand.

  • Quickly create live-update GUIs for Python packages using Markdown and a few custom HTML elements.
  • Just write in markdown + variables / UI types
  • Based on Jupyter

Development stage

This is currently in alpha stage development. Expect bugs, expect the experience to be rough around the edges at times. There are still significant changes in store for this library before it is ready to be classified as beta. However, I do encourage you to take it for a spin and journey with me, influencing what this will become.

Quick start

To use ScriptedForms you will need Python (>=3.5) on your computer. A platform independent way to install Python is to download and install the Anaconda Python distribution.

Once you have Python on your computer installingScriptedForms is as simple as typing the following into a terminal (or command prompt):

pip install scriptedforms

Then to use it create a markdown file within your current directory called quick-start.md with any plaintext editor (such asVisual Studio Code).Make the contents be the following:

# An example

<section-live>

<variable-string>your_name</variable-string>

```python
print('Hello {}!'.format(your_name))
```

</section-live>

Then run the following in your terminal

scriptedforms quick-start.md

If everything worked, a Scripted Form should open within your default browser.You should be able to type your name into the form and see the code field liveupdate with each key stroke:

Now within quick-start.md edit the markdown file by changing

# An example

to

# The form updates when I change it

and then press save. The form in the browser should then update to match whatyou just wrote.

Plotting and slider example

If you want to be a bit more adventurous see what happens if you add thefollowing to the end of the your quick-start.md file (or any otherScriptedForm):

#### Example slider use case

Using the slider and live sections combined with matplotlib plots you can
produce utilities like the following:

<section-start onLoad>

```python
t = np.linspace(-2*np.pi, 2*np.pi, 500)
omega = np.ones(2)
```

</section-start>

<section-live>

Angular frequencies ($\omega$):

<variable-slider label="$\omega [0]$" min="0" max="6" step="0.1">omega[0]</variable-slider>
<variable-slider label="$\omega [1]$" min="0" max="6" step="0.1">omega[1]</variable-slider>

```python
plt.figure(figsize=(5*1.618,5))

oscillation = np.sin(t[:, np.newaxis] * omega[np.newaxis, :])
summation = np.sum(oscillation, axis=1)

plt.plot(t, oscillation)
plt.plot(t, summation)

plt.xlim([-2*np.pi, 2*np.pi])
plt.ylim([-2.4, 2.4])
plt.title('Two sin curves and their summation')
plt.legend([
    r'$\omega [0] = {0:0.1f}$'.format(omega[0]),
    r'$\omega [1] = {0:0.1f}$'.format(omega[1]),
    'Summation'], loc='upper right')
plt.xlabel('time (seconds)')
plt.ylabel(r'$sin(\omega \times t)$');
```

</section-live>

This should produce what is seen in the following screenshot:

Click here to see a live version of this example on mybinder.org. This will run slower online on that server than when you are using it locally.

More features

For a markdown file that presents the majority of the features of scriptedformsseedetailed.form.md.Try writing some of the contents of that file into a ScriptedForm to see howthey work.

Platform/browser testing matrix

The following OS Browser combinations are explicitly tested using Sauce Labs:

Security notice

Be aware that ScriptedForms uses the Jupyter Notebook Server security model. When a user has access to the forms via the localhost web interface, should they have sufficient know how, they also have the ability to run arbitrary Python code without limitations.

By default only users on the local machine will be able to access the Jupyter Notebook Server which means if you trust a user to run code on their own machine then allowing them to use ScriptedForms will not cause issue. Only override these default settings if you understand and accept the security implications.

Furthermore do not run a scripted form unless you trust its origin. Given the reactive nature of ScriptedForms, code within the markdown template can run on form opening, as well as during usage.

[Advanced users only] Installing scriptedforms from the GitHub source

The majority of users will not need to pay attention to this section.

For those who wish to build scriptedforms from the source provided within thisrepository, instead of using pypi, the javascript bundle will need to be built.To do this you will need toinstall yarn and then run thefollowing in thedirectory containing the package.json file:

yarn
yarn build
yarn pip:install

This will install the node packages, build the javascript files and then runpip install -e . to install the python package.

License Change

I have re-released this code base under the Apache-2.0 license so that it maybe freely used within other projects without needing to adhere to the copyleftrequirements of the AGPL. The comments below regarding the previous choice oflicense will be left unchanged.

Justification for using a copyleft license

I desire to seed a Medical Physics open source community within Australia.Medical Physicists have been repeatedly blocked from giving code to thecommunity. There may be an opportunity for sharing however if there is anexisting IP agreement that distributed code or modifications will beprovided under the same license.

As such, to be able to seed a Medical Physics open source community withinAustralia I need to create something that helps Medical Physicists write theircode and have it licensed under a copyleft license.

I hope this is that package.

For more information on why you as a Medical Physicist might want to use theAGPL-3.0+ license read the benefits of AGPL-3.0+ for Medical Physics.

Justification for the inclusion of additional terms

A significant and justifiable fear within the Medical Physics community is thatshould code be shared the author of the code may be liable for negligence. Assuch specifically addressing negligence within the additional terms is a mustif this code base will become a seed to create a Medical Physics open sourcecommunity in Australia.

Within Australian courts if there is any ambiguity in liability exclusionclauses they will be interpreted narrowly. If liability for negligence is notexpressly excluded it may not be read as excluded within an Australian court(https://eprints.qut.edu.au/7404/1/open_source_book.pdf page 80).The same is true for clauses which seek to exclude liability for consequentialloss.

The AGPL-3.0+ does not explicitly mention negligence anywhere within itslicense text. The Apache-2.0 does. The AGPL-3.0+ in Section 7 does defineallowable additional terms. The negligence clauses within the Apache-2.0 fallunder these allowable additional terms so, as such, they have been included.

There are also other desirable features of the Apache-2.0 license such ascontribution, trademark, and warranty requirements. These were also included.

A note about the code sharing license requirement

If you only ever use this code internally within your company to create GUIsthe only people who need to have access to the source code are those userswhom you distribute the program to. Therefore you do not need to share yourcode outside of your company if your only users are within your company.

However there are significant benefits from sharing your code with thecommunity. Please read the benefits of AGPL-3.0+ for Medical Physics.

相关阅读

相关文章

相关问答

相关文档