Skip to content

Commit 5d5c77c

Browse files
committed
feat(ys): bootstrap
1 parent f4e66c4 commit 5d5c77c

File tree

9 files changed

+238
-0
lines changed

9 files changed

+238
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy to PyPi
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Test package"]
6+
types:
7+
- completed
8+
branches:
9+
- main
10+
status:
11+
- success
12+
13+
jobs:
14+
publish:
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.12'
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install build twine wheel scmver setuptools
30+
31+
- name: Get version from setup.py
32+
id: version
33+
run: |
34+
version=$(python3 setup.py --version)
35+
echo "version=$version" >> $GITHUB_ENV
36+
37+
- name: Build package
38+
run: python setup.py sdist bdist_wheel
39+
40+
- name: Publish package
41+
uses: pypa/gh-action-pypi-publish@v1.5.0
42+
with:
43+
user: __token__
44+
password: ${{ secrets.PYPI_API_TOKEN }}
45+
46+
- name: Create and push tag
47+
run: |
48+
git tag v$version
49+
git push origin v$version
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test package
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.12'
17+
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install build twine wheel scmver setuptools
22+
23+
- name: Get version from setup.py
24+
id: version
25+
run: |
26+
version=$(python3 setup.py --version)
27+
echo "version=$version" >> $GITHUB_ENV
28+
29+
- name: Build package
30+
run: python setup.py sdist bdist_wheel
31+
32+
- name: Install package
33+
run: pip install dist/pulser_scaleway-${version}-py3-none-any.whl
34+
35+
- name: Install test
36+
run: pip install -r tests/requirements.txt
37+
38+
- name: Run test
39+
run: pytest -s --showprogress -vv tests/
40+
env:
41+
YARDSTIQ_SCALEWAY_PROJECT_ID: ${{ secrets.STG_YARDSTIQ_SCALEWAY_PROJECT_ID }}
42+
YARDSTIQ_SCALEWAY_SECRET_KEY: ${{ secrets.STG_YARDSTIQ_SCALEWAY_API_TOKEN }}
43+
YARDSTIQ_SCALEWAY_API_URL: ${{ secrets.STG_YARDSTIQ_SCALEWAY_API_URL }}

CONTRIBUTING.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contribute to `yardstiq-scaleway`
2+
3+
`yardstiq-scaleway` is Apache 2.0 licensed and accepts contributions via GitHub.
4+
This document will cover how to contribute to the project and report issues.
5+
6+
<p align="center"><img width="50%" src="docs/static_files/sdk-artwork.png" /></p>
7+
8+
## Topics
9+
10+
- [Reporting Security Issues](#reporting-security-issues)
11+
- [Reporting Issues](#reporting-issues)
12+
- [Suggesting feature](#suggesting-feature)
13+
- [Contributing Code](#contributing-code)
14+
- [Community Guidelines](#community-guidelines)
15+
16+
## Reporting security issues
17+
18+
At Scaleway we take security seriously.
19+
If you have any issue regarding security, please notify us by sending an email to [security@scaleway.com](mailto:security@scaleway.com).
20+
21+
Please _DO NOT_ create a GitHub issue.
22+
23+
We will follow up with you promptly with more information and a plan for remediation.
24+
We currently do not offer a paid security bounty program, but we would love to send some Scaleway swag your way along with our deepest gratitude for your assistance in making Scaleway a more secure Cloud ecosystem.
25+
26+
## Reporting issues
27+
28+
A great way to contribute to the project is to send a detailed report when you encounter a bug.
29+
We always appreciate a well-written, thorough bug report, and will thank you for it!
30+
Before opening a new issue, we appreciate you reviewing open issues to see if there are any similar requests.
31+
If there is a match, thumbs up the issue with a 👍 and leave a comment if you have additional information.
32+
33+
When reporting an issue, include the following:
34+
35+
- The version of `yardstiq-scaleway` you are using
36+
- Python version
37+
- The target backend is applicable
38+
39+
## Suggesting a feature
40+
41+
When requesting a feature, some of the questions we want to answer are:
42+
43+
- What value does this feature bring to end users?
44+
- How urgent is the need (nice to have feature or need to have)?
45+
- Does this align with the goals of `yardstiq-scaleway`?
46+
47+
## Contributing code
48+
49+
### Submit code
50+
51+
To submit code:
52+
53+
- Create a fork of the project
54+
- Create a topic branch from where you want to base your work (usually master)
55+
- Add tests to cover contributed code
56+
- Push your commit(s) to your topic branch on your fork
57+
- Open a pull request against `yardstiq-scaleway` master branch that follows [PR guidelines](#pull-request-guidelines)
58+
59+
The maintainers of `yardstiq-scaleway` use a "Let's Get This Merged" (LGTM) message in the pull request to note that the commits are ready to merge.
60+
After one or more maintainer states LGTM, we will merge.
61+
If you have questions or comments on your code, feel free to correct these in your branch through new commits.
62+
63+
### Pull Request Guidelines
64+
65+
The goal of the following guidelines is to have Pull Requests (PRs) that are fairly easy to review and comprehend, and code that is easy to maintain in the future.
66+
67+
- **Pull Request title should be clear** on what is being fixed or added to the code base.
68+
If you are addressing an open issue, please start the title with "fix: #XXX" or "feature: #XXX"
69+
- **Keep it readable for human reviewers** and prefer a subset of functionality (code) with tests and documentation over delivering them separately
70+
- **Don't forget commenting code** to help reviewers understand
71+
- **Notify Work In Progress PRs** by prefixing the title with `[WIP]`
72+
- **Please, keep us updated.**
73+
We will try our best to merge your PR, but please notice that PRs may be closed after 30 days of inactivity.
74+
75+
Your pull request should be rebased against the current master branch. Please do not merge
76+
the current master branch in with your topic branch, nor use the Update Branch button provided
77+
by GitHub on the pull request page.
78+
79+
Keep in mind only the **Pull Request Title** will be used as commit message as we stash all commits on merge.
80+
81+
## Community guidelines
82+
83+
Thank you for reading through all of this, if you have any question feel free to [reach us](README.md#reach-us)!

examples/.keep

Whitespace-only changes.

pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "yardstiq-scaleway"
7+
version = "0.1.0"
8+
description = "Yardstiq QPU provider for Scaleway QaaS"
9+
requires-python = ">=3.12"
10+
11+
# Dépendances du plugin
12+
dependencies = [
13+
"yardstiq>=0.1.0",
14+
"scaleway-qaas-client>=0.1.23"
15+
]
16+
17+
[project.entry-points."yardstiq.plugins"]
18+
scaleway = "yardstiq_scaleway.plugin_loader"

tests/.keep

Whitespace-only changes.

tests/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pytest
2+
pytest-dependency
3+
pytest-progress

yardstiq_scaleway/plugin_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .scaleway_provider import ScalewayProvider
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from typing import Any, Dict, List
2+
3+
from yardstiq.core import provider, Provider, Backend
4+
5+
from scaleway_qaas_client.v1alpha1 import QaaSClient, QaaSPlatform
6+
7+
8+
@provider("scaleway")
9+
class ScalewayProvider(Provider):
10+
def __init__(self, **kwargs):
11+
super().__init__("scaleway")
12+
13+
secret_key = kwargs.get("scaleway_secret_key", None)
14+
project_id = kwargs.get("scaleway_project_id", None)
15+
api_url = kwargs.get("scaleway_api_url", None)
16+
17+
self.__client = QaaSClient(project_id=project_id, secret_key=secret_key, url=api_url)
18+
19+
def get_backend(self, name : str) -> Backend:
20+
platforms = self.__client.list_platforms(name=name)
21+
22+
if not platforms or len(platforms) == 0:
23+
raise ValueError(f"Backend '{name}' not found in Scaleway providers")
24+
25+
return self._platform_to_backend(self, platforms[0])
26+
27+
def list_backends(self) -> List[Backend]:
28+
platforms = self.__client.list_platforms()
29+
30+
if not platforms:
31+
raise ValueError(f"Backend not found in Scaleway providers")
32+
33+
if len(platforms) == 0:
34+
return []
35+
36+
return list(map(lambda p: self._platform_to_backend(p), platforms))
37+
38+
def _platform_to_backend(self, platform: QaaSPlatform) -> Backend:
39+
return Backend(provider=self)

0 commit comments

Comments
 (0)