Skip to content

Commit 0808cbe

Browse files
author
jitsuineccles
authored
#3448 Add standard opensource files (#5)
1 parent c334f98 commit 0808cbe

5 files changed

Lines changed: 290 additions & 48 deletions

File tree

BUILDING.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Jitsuin Archivist Client Development
2+
3+
## Pre-requisites
4+
5+
Required tools for this repo are task-runner and docker-ce.
6+
7+
Install task runner: https://github.com/go-task/task
8+
Install docker-ce: https://docs.docker.com/get-docker/
9+
10+
## Workflow
11+
12+
To see what options are available simply execute:
13+
14+
```bash
15+
task
16+
```
17+
18+
All development is done using a docker image. To create the image execute
19+
the following command. This command only has to be repeated if requirements.txt
20+
or requirements-dev.txt change.
21+
22+
Dependencies are defined in requirements.txt for the archivist package and
23+
requirements-dev.txt for the tools used to build, test and publish the
24+
archivist package.
25+
26+
To build the docker builder image:
27+
```bash
28+
task builder
29+
```
30+
31+
Make a change to the code and validate the changes:
32+
33+
```bash
34+
task check
35+
```
36+
37+
If ok run the unittests:
38+
39+
```bash
40+
task unittests
41+
```
42+
43+
If 100% coverage and no test failures generate the wheel:
44+
45+
```bash
46+
task wheel
47+
```
48+
49+
Lastly to publish the package to PyPi:
50+
51+
```bash
52+
task publish
53+
```
54+
55+
Note that this requires credentials and will only normally be done by a Jitsuin
56+
representative.
57+
58+

CODE_OF_CONDUCT.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Jitsuin observes the [CNCF Community Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md), reproduced below for emphasis.
2+
3+
### Contributor Code of Conduct
4+
5+
As contributors and maintainers of this project, and in the interest of fostering
6+
an open and welcoming community, we pledge to respect all people who contribute
7+
through reporting issues, posting feature requests, updating documentation,
8+
submitting pull requests or patches, and other activities.
9+
10+
We are committed to making participation in this project a harassment-free experience for
11+
everyone, regardless of level of experience, gender, gender identity and expression,
12+
sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
13+
religion, or nationality.
14+
15+
Examples of unacceptable behavior by participants include:
16+
17+
* The use of sexualized language or imagery
18+
* Personal attacks
19+
* Trolling or insulting/derogatory comments
20+
* Public or private harassment
21+
* Publishing others' private information, such as physical or electronic addresses,
22+
without explicit permission
23+
* Other unethical or unprofessional conduct.
24+
25+
Project maintainers have the right and responsibility to remove, edit, or reject
26+
comments, commits, code, wiki edits, issues, and other contributions that are not
27+
aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers
28+
commit themselves to fairly and consistently applying these principles to every aspect
29+
of managing this project. Project maintainers who do not follow or enforce the Code of
30+
Conduct may be permanently removed from the project team.
31+
32+
This code of conduct applies both within project spaces and in public spaces
33+
when an individual is representing the project or its community.
34+
35+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a Jitsuin administrator on <support@jitsuin.com>.
36+
37+
This Code of Conduct is adapted from the Contributor Covenant
38+
(http://contributor-covenant.org), version 1.2.0, available at
39+
http://contributor-covenant.org/version/1/2/0/
40+

CONTRIBUTING.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Contributing to jitsuin-archivist #
2+
3+
Thanks for taking the time to contribute to jitsuin-archivist!
4+
5+
Contributing is not limited to writing code and submitting a PR. Feel free to submit an
6+
[issue](https://github.com/jitsuin-inc/archivist-python/issues/new/choose) or comment on an existing one
7+
to report a bug, provide feedback, or suggest a new feature.
8+
9+
Of course, contributing code is more than welcome! To keep things simple, if you're fixing a small issue,
10+
you can simply submit a PR and we will pick it up. However, if you're planning to submit a bigger PR to implement
11+
a new feature or fix a relatively complex bug, please open an issue that explains the change and the motivation for it.
12+
If you're addressing a bug, please explain how to reproduce it.
13+
14+
## Pull request and git commit guidance
15+
16+
### Opening PRs and organizing commits
17+
PRs should generally address only 1 issue at a time. If you need to fix two bugs, open two separate PRs.
18+
This will keep the scope of your pull requests smaller and allow them to be reviewed and merged more quickly.
19+
20+
When possible, fill out as much detail in the pull request template as is reasonable.
21+
Most important is to reference the GitHub issue that you are addressing with the PR.
22+
23+
**NOTE:** GitHub has
24+
[a feature](https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)
25+
that will automatically close issues referenced with a keyword (such as "Fixes") by a PR or commit once the PR/commit is merged.
26+
Don't use these keywords. We don't want issues to be automatically closed. We want our testers to independently verify and close them.
27+
28+
Generally, pull requests should consist of a single logical commit.
29+
However, if your PR is for a large feature, you may need a more logical breakdown of commits.
30+
This is fine as long as each commit is a single logical unit.
31+
32+
### Writing good commit messages
33+
Git commit messages should explain the how and why of your change and be separated into a brief subject line
34+
followed by a more detailed body. When in doubt, follow this guide for good commit messages and
35+
you can’t go wrong: https://chris.beams.io/posts/git-commit/.
36+
37+
One particularly useful point made in the above guide is regarding commit subject lines:
38+
39+
> A properly formed Git commit subject line should always be able to complete the following sentence:
40+
>
41+
> - If applied, this commit will <ins>your subject line here</ins>
42+
43+
A simple but effective convention to follow for commits is the “problem / solution” pattern. It looks like this:
44+
```
45+
<Subject>
46+
47+
Problem: <Statement of problem>
48+
49+
Solution: <Statement of solution>
50+
```
51+
52+
As an example, here is a commit taken from the rancher/rancher repo:
53+
```
54+
commit b71ce2892eecb7c87a5212e3486f1de899a694aa
55+
Author: Dan Ramich <danold215@gmail.com>
56+
Date: Tue Jun 19 11:56:52 2018 -0700
57+
58+
Add Validator for RoleTemplate
59+
60+
Problem:
61+
Builtin RoleTemplates can be updated through the API
62+
63+
Solution:
64+
Add a Validator to ensure the only field that can be changed on a
65+
builtin RoleTemplate is 'locked'
66+
```
67+
68+
### Reviewing, addressing feedback, and merging
69+
Generally, pull requests need two approvals from maintainers to be merged.
70+
71+
When addressing review feedback, it is helpful to the reviewer if additional changes are made in new commits.
72+
This allows the reviewer to easily see the delta between what they previously reviewed and the changes you added
73+
to address their feedback.
74+
75+
Once a PR has the necessary approvals, it can be merged.
76+
Here’s how the merge should be handled:
77+
- All PR's should use the “Squash and merge” option.
78+
- Commits and their messages should be consistent - each commit in the PR should form a logical unit with working code.
79+
- The first change requested by a Jitsuin reviewer will be to reorganise the commits into a clean logical structure.
80+
- The smaller a PR the more likely and more easily that the change will be approved.
81+
- Any changes requested by a reviewer should be committed as a 'fixup' commit against the original commit in the PR.
82+
- Once approval is granted any 'fixup' commits should be merged into their respective commits using 'git rebase -i --autosquash'.
83+
84+
## Developer Certificate Of Origin ##
85+
86+
To contribute to this project, you must agree to the Developer Certificate of Origin (DCO) for each commit you make.
87+
The DCO is a simple statement that you, as a contributor, have the legal right to make the contribution.
88+
89+
See the [DCO](DCO) file for the full text of what you must agree to.
90+
91+
To signify that you agree to the DCO for a commit, you add a line to the git
92+
commit message:
93+
94+
```txt
95+
Signed-off-by: Jane Smith <jane.smith@example.com>
96+
```
97+
98+
In most cases, you can add this signoff to your commit automatically with the
99+
`-s` flag to `git commit`. Please use your real name and a reachable email address.

DCO

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Developer Certificate of Origin
2+
Version 1.1
3+
4+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
5+
1 Letterman Drive
6+
Suite D4700
7+
San Francisco, CA, 94129
8+
9+
Everyone is permitted to copy and distribute verbatim copies of this
10+
license document, but changing it is not allowed.
11+
12+
13+
Developer's Certificate of Origin 1.1
14+
15+
By making a contribution to this project, I certify that:
16+
17+
(a) The contribution was created in whole or in part by me and I
18+
have the right to submit it under the open source license
19+
indicated in the file; or
20+
21+
(b) The contribution is based upon previous work that, to the best
22+
of my knowledge, is covered under an appropriate open source
23+
license and I have the right under that license to submit that
24+
work with modifications, whether created in whole or in part
25+
by me, under the same open source license (unless I am
26+
permitted to submit under a different license), as indicated
27+
in the file; or
28+
29+
(c) The contribution was provided directly to me by some other
30+
person who certified (a), (b) or (c) and I have not modified
31+
it.
32+
33+
(d) I understand and agree that this project and the contribution
34+
are public and that a record of the contribution (including all
35+
personal information I submit with it, including my sign-off) is
36+
maintained indefinitely and may be redistributed consistent with
37+
this project or the open source license(s) involved.
38+

README.md

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,68 @@ The standard Jitsuin Archivist python client.
55
Please note that the canonical API for Jitsuin Archivist is always the REST API
66
documented at https://jitsuin-archivist.readthedocs.io
77

8-
# Development
9-
10-
## Pre-requisites
11-
12-
Required tools for this repo are task-runner and docker-ce.
13-
14-
Install task runner: https://github.com/go-task/task
15-
Install docker-ce: https://docs.docker.com/get-docker/
16-
17-
## Workflow
18-
19-
To see what options are available simply execute:
20-
21-
```bash
22-
task
23-
```
24-
25-
All development is done using a docker image. To create the image execute
26-
the following command. This command only has to be repeated if requirements.txt
27-
or requirements-dev.txt change.
28-
29-
Dependencies are defined in requirements.txt for the archivist package and
30-
requirements-dev.txt for the tools used to build, test and publish the
31-
archivist package.
32-
33-
To build the docker builder image:
34-
```bash
35-
task builder
36-
```
37-
38-
Make a change to the code and validate the changes:
39-
40-
```bash
41-
task check
42-
```
8+
# Installation
439

44-
If ok run the unittests:
10+
Use standard python pip utility:
4511

4612
```bash
47-
task unittests
13+
python3 -m pip install jitsuin-archivist
4814
```
4915

50-
If 100% coverage and no test failures generate the wheel:
16+
One can then use the examples code to create assets:
17+
18+
```python
19+
from archivist.archivist import Archivist
20+
from archivist.errors import ArchivistError
21+
22+
# Oauth2 token that grants access
23+
with open(".auth_token", mode='r') as tokenfile:
24+
authtoken = tokenfile.read().strip()
25+
26+
# Initialize connection to Archivist - the URL for production will be different to this URL
27+
arch = Archivist(
28+
"https://soak-0-avid.engineering-k8s-stage-2.dev.wild.jitsuin.io",
29+
auth=authtoken,
30+
)
31+
32+
# Create a new asset
33+
attrs = {
34+
"arc_display_name": "display_name", # Asset's display name in the user interface
35+
"arc_description": "display_description", # Asset's description in the user interface
36+
"arc_display_type": "desplay_type", # Arc_display_type is a free text field
37+
# allowing the creator of
38+
# an asset to specify the asset
39+
# type or class. Be careful when setting this:
40+
# assets are grouped by type and
41+
# sharing policies can be
42+
# configured to share assets based on
43+
# their arc_display_type.
44+
# So a mistake here can result in asset data being
45+
# under- or over-shared.
46+
"some_custom_attribute": "value" # You can add any custom value as long as
47+
# it does not start with arc_
48+
}
49+
behaviours = ["Attachments", "Firmware", "LocationUpdate", "Maintenance", "RecordEvidence"]
50+
51+
# The first argument is the behaviours of the asset
52+
# The second argument is the attributes of the asset
53+
# The third argument is wait for confirmation:
54+
# If @confirm@ is True then this function will not
55+
# return until the asset is confirmed on the blockchain and ready
56+
# to accept events (or an error occurs)
57+
# After an asset is submitted to the blockchain (submitted),
58+
# it will be in the "Pending" status.
59+
# Once it is added to the blockchain, the status will be changed to "Confirmed"
60+
try:
61+
asset = arch.assets.create(behaviours, attrs=attrs, confirm=True)
62+
except Archivisterror as ex:
63+
print("error", ex)
64+
else:
65+
print("asset", asset)
5166

52-
```bash
53-
task wheel
54-
```
55-
56-
Lastly to publish the package to PyPi:
57-
58-
```bash
59-
task publish
6067
```
6168

62-
Note that this requires credentials and will only normally be done by a Jitsuin
63-
representative.
69+
# Development
6470

71+
See BUILDING.md
6572

0 commit comments

Comments
 (0)