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

add poetry support #624

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'poetry'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine build
run: poetry install
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
python -m build
python -m twine upload --repository pypi dist/*
poetry config pypi-token.pypi "$PYPI_TOKEN"
poetry build
poetry publish
13 changes: 8 additions & 5 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ jobs:
platform: [ubuntu-latest, macos-latest, windows-latest]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add 3.11 to python-version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

h5py doesn't have prebuild for 3.11 which leads python to compile it and cause error. I would recommend to wait h5py upload precompile binary to pypi.

steps:
- uses: actions/checkout@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox-gh-actions
pip install tox
poetry add -D tox-gh-actions=^2.0.0
poetry install
poetry run python -m pip install --upgrade pip
- name: Install precompiled gdstk
if: matrix.platform == 'windows-latest'
run: |
pip install gdstk --only-binary=gdstk
- name: Test with tox
run: tox
run: poetry run tox
52 changes: 47 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,61 @@ The source code for our documentation is [here](https://github.com/flexcompute-r
Note that while this front end package is open source, to run simulations on Flexcompute servers requires an account with credits.
You can sign up [here](https://client.simulation.cloud/register-waiting). While it's currently a waitlist for new users, we will be rolling out to many more users in the coming weeks! See [this page](https://flexcompute-tidy3ddocumentation.readthedocs-hosted.com/quickstart.html) in our documentation for more details.

### Installing the package using pip
### Installing the front end

#### Using pip (recommended)

The easiest way to install tidy3d is through [pip](https://pip.pypa.io/en/stable/).

```
pip install tidy3d
```

### (Alternativelty) installing from source
### Installing from source

For development purposes, you can download and install the package from source as:
For development purposes, and to get the latest development versions, you can download and install the package from source as:

```
git clone https://github.com/flexcompute/tidy3d.git
cd tidy3d
pip install -e .
```

### Did it work?
### Configuring and authentication

Authentication (linking the front end to your account) will be done via an API key moving forward.

You can find your API key in the web interface http://tidy3d.simulation.cloud

After signing in, copy the API key for the next steps.

To set up the API key to work with Tidy3D, we need to store it either in the `~/.tidy3d/config` file or an environment variable.

You can set it up using one of three following options.

#### Command line (recommended)

``tidy3d configure`` and then enter your API key when prompted.

#### Manually

For an API key of `{your_api_key}`, you may run

``echo 'apikey = "{your_api_key}"' > ~/.tidy3d/config``

You can verify the installation worked by running:
or manually insert the line `'apikey = "{your_api_key}"` in the `~/.tidy3d/config` file.

#### Environment Variable

Set the `SIMCLOUD_API_KEY` environment variable to your API key (in quotes).

``export SIMCLOUD_API_KEY="{your_api_key}"``

### Testing the installation and authentication

#### Front end package

You can verify the front end installation worked by running:

```
python -c "import tidy3d as td; print(td.__version__)"
Expand All @@ -61,6 +95,14 @@ and it should print out the version number, for example:
1.0.0
```

#### Authentication

To test the web / authentication

```
python -c "import tidy3d.web"
```

## Issues / Feedback / Bug Reporting

Your feedback helps us immensely!
Expand Down
2,007 changes: 2,007 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

65 changes: 60 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,64 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
[tool.poetry]
name = "tidy3d"
version = "1.9.0"
description = ""
authors = ["Tyler Hughes <tyler@flexcompute.com>"]
readme = "README.md"
packages = [
{ include = "tidy3d" },
{ include = "tidy3d/web" },
{ include = "tidy3d/plugins" },
]
build-backend = "setuptools.build_meta"


[tool.poetry.dependencies]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like we need more granular control over the dependencies like we have currently.

  • core core packages, could be installed with poetry install --only core
  • web things needed for web only
  • basic the default install, core + web + scipy should be installed by default.
  • devshould be optional, ie poetry install --with dev

More info on dependency groups
Our current dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems poetry doesn't support one group declare other groups as dependencies. We maybe thinking of an other orchestrate.

python = "^3.7.2"
shapely = "^2.0.0"
scipy = [{ python = "~3.7", version = "^1.6.0" },
{ python = "~3.8", version = "^1.8.0" },
{ python = "^3.9", version = "^1.9.0" }]
numpy = [{ python = "~3.7", version = "^1.19.0" },
{ python = "~3.8", version = "^1.20.0" },
{ python = "^3.9", version = "^1.23.0" }]
matplotlib = [{ python = "~3.7", version = "~3.5" },
{ python = "^3.8", version = "^3.6" }]
pandas = [{ python = "~3.7", version = "^1.3.0"}, {python = "^3.8", version = "^1.5.0"}]
xarray = "^0.20.2"
pyroots = "^0.5.0"
importlib-metadata = "<5.0.0"
h5netcdf = "^1.1.0"
h5py = "^3.7.0"
rich = "^12.6.0"
pydantic = "^1.10.2"
pyyaml = "^6.0"
dask = "~2022.02.0"
boto3 = "^1.26.31"
requests = "^2.28.1"
pyjwt = "^2.6.0"
toml = "^0.10.2"
click = "^8.1.3"

[tool.poetry.group.dev.dependencies]
black = "^22.12.0"
pylint = "^2.15.8"
pytest = "^7.2.0"
pytest-timeout = "^2.1.0"
gdspy = "^1.6.12"
memory-profiler = "^0.61.0"
dill = "^0.3.6"
tox = "^3.0.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.black]
line-length = 100


[tool.pytest.ini_options]
filterwarnings = 'ignore::DeprecationWarning'

[tool.poetry.scripts]
tidy3d = "tidy3d.web.cli:tidy3d_cli"
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

13 changes: 0 additions & 13 deletions requirements/basic.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements/core.txt

This file was deleted.

14 changes: 0 additions & 14 deletions requirements/dev.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements/web.txt

This file was deleted.

54 changes: 0 additions & 54 deletions setup.py

This file was deleted.

23 changes: 23 additions & 0 deletions tests/test_web/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os.path
import shutil

from click.testing import CliRunner

from tidy3d.web.cli import tidy3d_cli
from tidy3d.web.cli.app import CONFIG_FILE


def test_tidy3d_cli():

if os.path.exists(CONFIG_FILE):
shutil.move(CONFIG_FILE, f"{CONFIG_FILE}.bak")

runner = CliRunner()
result = runner.invoke(tidy3d_cli, ["configure"], input="apikey")

assert result.exit_code == 0
if os.path.exists(CONFIG_FILE):
os.remove(CONFIG_FILE)

if os.path.exists(f"{CONFIG_FILE}.bak"):
shutil.move(f"{CONFIG_FILE}.bak", CONFIG_FILE)
3 changes: 3 additions & 0 deletions tests/test_web/test_webapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class MockResponse:
def json():
return {}

def raise_for_status(self):
pass


class MockResponseInfoOk(MockResponse):
"""response if web.getinfo(task_id) and task_id found"""
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Defines the front end version of tidy3d"""

__version__ = "1.8.2"
__version__ = "1.9.0"

PIP_NAME = "tidy3d-beta"
1 change: 1 addition & 0 deletions tidy3d/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from .webapi import get_tasks, delete_old, download_json, download_log, load_simulation
from .container import Job, Batch, BatchData
from .auth import get_credentials
from .cli import tidy3d_cli
4 changes: 4 additions & 0 deletions tidy3d/web/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
tidy3d command line tool.
"""
from .app import tidy3d_cli
Loading