Skip to content

Commit

Permalink
Merge pull request #31 from KristinaGomoryova/pypi_cleanup
Browse files Browse the repository at this point in the history
Pypi cleanup
  • Loading branch information
hechth authored Jul 15, 2024
2 parents e475977 + 71dc774 commit 6522f37
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 130 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.1] - 1900-12-31
## [0.1.0] - 2024-07-15

### Added

- function to read the metadata or alkane file in csv/tsv/xls/xlsx format
- function to process the metadata file: validate file names, derive and rearrange additional metadata columns
- function to save the processed metadata or alkane dataframe as tsv

### Removed

### Changed
Expand Down
2 changes: 2 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ repository-code: "https://github.com/RECETOX/rcx-tk"
keywords:
- rcx
- process metadata
- alkanes
- metabolomics
message: "If you use this software, please cite it using these metadata."
license: MIT
2 changes: 0 additions & 2 deletions NOTICE

This file was deleted.

88 changes: 40 additions & 48 deletions README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,31 @@

If you're looking for user documentation, go [here](README.md).

## Development install
## Package installation

```shell
# Create a virtual environment, e.g. with
python -m venv env
To create a new environment, use the micromamba:

```console
micromamba create -n rcx-tk poetry
micromamba activate rcx-tk
```
To install all dependencies specified in the `pyproject.toml` file, use poetry:

# activate virtual environment
source env/bin/activate
```console
poetry install
```

# make sure to have a recent version of pip and setuptools
python -m pip install --upgrade pip setuptools
A command line interface was also implemented using Click, so the package can be run by either using python3:

# (from the project root directory)
# install rcx_tk as an editable package
python -m pip install --no-cache-dir --editable .
# install development dependencies
python -m pip install --no-cache-dir --editable .[dev]
```console
python3 -m rcx_tk --method='' <path-to-input-data> <path-to-output-data>
```

Afterwards check that the install directory is present in the `PATH` environment variable.
or using poetry:

```console
poetry run rcx_tk --method='' <file-path-to-input-data> <file-path-to-output-data>
```

## Running the tests

Expand Down Expand Up @@ -116,9 +121,9 @@ make doctest
Bumping the version across all files is done with [bump-my-version](https://github.com/callowayproject/bump-my-version), e.g.

```shell
bump-my-version bump major # bumps from e.g. 0.3.2 to 1.0.0
bump-my-version bump minor # bumps from e.g. 0.3.2 to 0.4.0
bump-my-version bump patch # bumps from e.g. 0.3.2 to 0.3.3
poetry version major # bumps from e.g. 0.3.2 to 1.0.0
poetry version minor # bumps from e.g. 0.3.2 to 0.4.0
poetry version patch # bumps from e.g. 0.3.2 to 0.3.3
```

## Making a release
Expand All @@ -145,50 +150,37 @@ In a new terminal:
# has the state of origin/main branch
cd $(mktemp -d rcx_tk.XXXXXX)
git clone [email protected]:RECETOX/rcx-tk .
```

# make sure to have a recent version of pip and the publishing dependencies
python -m pip install --upgrade pip
python -m pip install .[publishing]

# create the source distribution and the wheel
python -m build
Create and activate a new environment:

# upload to test pypi instance (requires credentials)
python -m twine upload --repository testpypi dist/*
```console
micromamba create -n rcx-tk-pypi poetry
micromamba activate rcx-tk-pypi
```

Visit
[https://test.pypi.org/project/rcx_tk](https://test.pypi.org/project/rcx_tk)
and verify that your package was uploaded successfully. Keep the terminal open, we'll need it later.
Create an account on PyPI.

In a new terminal, without an activated virtual environment or an env directory:
In the Account settings, find the API tokens section and click on "Add API token". Copy your token.

```shell
cd $(mktemp -d rcx_tk-test.XXXXXX)
Add your API token to Poetry:

# prepare a clean virtual environment and activate it
python -m venv env
source env/bin/activate
```console
poetry config pypi-token.pypi your-api-token
```

# make sure to have a recent version of pip and setuptools
python -m pip install --upgrade pip
Build your project:

# install from test pypi instance:
python -m pip -v install --no-cache-dir \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple rcx_tk
```console
poetry build
```

Check that the package works as it should when installed from pypitest.

Then upload to pypi.org with:
Publish your package to PyPI:

```shell
# Back to the first terminal,
# FINAL STEP: upload to PyPI (requires credentials)
python -m twine upload dist/*
```console
poetry publish
```

### (3/3) GitHub

Don't forget to also make a [release on GitHub](https://github.com/RECETOX/rcx-tk/releases/new). If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it.
Don't forget to also make a [release on GitHub](https://github.com/RECETOX/rcx-tk/releases/new). If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Badges

(Customize these badges with your own links, and check https://shields.io/ or https://badgen.net/ to see which other badges are available.)

| fair-software.eu recommendations | |
| :-- | :-- |
| (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)](https://github.com/RECETOX/rcx-tk) |
Expand All @@ -21,9 +19,16 @@

## How to use rcx_tk

Tools for internal use
`rcx-tk` package provides tools to process the metadata or alkane files.

On the input, the user is expected to supply a path to the metadata/alkane file in tsv/csv/xls/xlsx file. The file is then converted to a dataframe which is further processed. The main steps are:

- columns rearrangement
- validation of the file names
- validation that the `injectionNumber` column is of integer type
- derivation of new metadata: `sampleName`, `sequenceIdentifier`, `sampleIdentifier` and `localOrder`

The project setup is documented in [project_setup.md](project_setup.md). Feel free to remove this document (and/or the link to this document) if you don't need it.
Finally, the processed dataframe is saved into user-defined location.

## Installation

Expand All @@ -32,12 +37,23 @@ To install rcx_tk from GitHub repository, do:
```console
git clone [email protected]:RECETOX/rcx-tk.git
cd rcx-tk
python -m pip install .
poetry install
```

The main functions are process_metadata_file and process_alkane_ri_file.

The tool can be run also using command-line interface, either by the python3 or poetry:

```console
python3 <path-to-__main.py__> --method='' <path-to-input-data> <path-to-output-data>
```

```console
poetry run rcx_tk --method='' <file-path-to-input-data> <file-path-to-output-data>
```
## Documentation

Include a link to your project's full documentation here.
The project is documented [here](https://rcx-tk.readthedocs.io/en/latest/?badge=latest).

## Contributing

Expand Down
47 changes: 0 additions & 47 deletions next_steps.md

This file was deleted.

27 changes: 14 additions & 13 deletions project_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ checklist](https://guide.esciencecenter.nl/#/best_practices/checklist).

This repository is set up with Python versions:

- 3.8
- 3.9
- 3.10
- 3.11
- 3.12

Expand All @@ -23,19 +20,23 @@ versions.

## Package management and dependencies

You can use either pip or conda for installing dependencies and package management. This repository does not force you
to use one or the other, as project requirements differ. For advice on what to use, please check [the relevant section
of the
guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=dependencies-and-package-management).
For installing the dependencies and package management, [micromamba](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html) and [poetry](https://python-poetry.org/) have been used.

- Runtime dependencies should be added to `pyproject.toml` in the `dependencies` list under `[project]`.
- Development dependencies should be added to `pyproject.toml` in one of the lists under `[project.optional-dependencies]`.
The dependencies are listed in the `pyproject.toml` file under the section `[tool.poetry.dependencies]` and `[tool.poetry.group.dev.dependencies]`.

## Packaging/One command install

You can distribute your code using PyPI.
[The guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=building-and-packaging-code) can
help you decide which tool to use for packaging.
To create a new environment, use the micromamba:

```console
micromamba create -n rcx-tk poetry
micromamba activate rcx-tk
```
To install all dependencies specified in the `pyproject.toml` file, use poetry:

```console
poetry install
```

## Testing and code coverage

Expand Down Expand Up @@ -114,4 +115,4 @@ help you decide which tool to use for packaging.
## NOTICE

- List of attributions of this project and Apache-license dependencies
- [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/licensing?id=notice)
- [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/licensing?id=notice)
20 changes: 7 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rcx-tk"
version = "0.1.0"
description = "This package adjusts and cleans the metadata file provided by a user."
authors = ["Zargham Ahmad <[email protected]>" ]
authors = ["Zargham Ahmad <[email protected]>" , "Kristina Gomoryova <[email protected]>"]
license = "MIT"
readme = "README.md"
keywords = ["metadata", "alkanes", "metabolomics"]
Expand Down Expand Up @@ -117,17 +117,11 @@ known-first-party = ["rcx_tk"]
force-single-line = true
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]

[[tool.bumpversion.files]]
filename = "src/rcx_tk/__init__.py"

[[tool.bumpversion.files]]
filename = "pyproject.toml"

[[tool.bumpversion.files]]
filename = "CITATION.cff"

[[tool.bumpversion.files]]
filename = "docs/conf.py"

[tool.poetry.scripts]
rcx_tk = "rcx_tk.__main__:main"

[tool.poetry_bumpversion.file."src/rcx_tk/__init__.py"]
[tool.poetry_bumpversion.file."CITATION.cff"]
[tool.poetry_bumpversion.file."docs/conf.py"]
[tool.poetry_bumpversion.file."pyproject.toml"]

0 comments on commit 6522f37

Please sign in to comment.