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

Merge develop into main, for release (2.0.0) #300

Merged
merged 30 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a9c6205
Renamed mepo.d -> src/mepo
pchakraborty Mar 12, 2024
3443483
Adjusted paths for importing modules
pchakraborty Mar 12, 2024
e2d253f
Renamed doc -> docs
pchakraborty Mar 12, 2024
d513f89
Moved test directory out of src
pchakraborty Mar 12, 2024
277ba9d
Updated path in top-level mepo script
pchakraborty Mar 12, 2024
3a021d3
Added pyproject.toml for pip installation
pchakraborty Mar 12, 2024
b9e8c71
Some fixes
pchakraborty Mar 12, 2024
6f9608d
Updated paths for helper script
pchakraborty Mar 13, 2024
749869c
Fixed doc generation
pchakraborty Mar 13, 2024
4de9a14
Moved helper script to the bin directory
pchakraborty Mar 14, 2024
4e250e1
Updated gitignore
pchakraborty Mar 14, 2024
9a043c4
Update required Python version in bin/mepo
pchakraborty Mar 22, 2024
33017cd
Updated CHANGELOG
pchakraborty Mar 22, 2024
5027609
This release should probably be 2.0.0
pchakraborty Mar 22, 2024
6b1cad4
Merge pull request #269 from GEOS-ESM/feature/pchakrab/py-project-pip…
tclune Mar 23, 2024
809e58b
Fix small typo
mathomp4 Mar 25, 2024
1d54e5e
Merge pull request #271 from GEOS-ESM/bugfix/mathomp4/typo
pchakraborty Mar 25, 2024
ba68a31
Patch for reading mepo1 state
pchakraborty Apr 30, 2024
809d1ae
Cleaner code for patching in case of mepo1 state + a warning
pchakraborty May 1, 2024
1afb682
Merge pull request #279 from GEOS-ESM/hotfix/pchakrab/pickle-patch
mathomp4 May 1, 2024
53ffe8a
Python package with expanded testing (#278)
pchakraborty May 15, 2024
8c90e80
Make doc generation work again (#286)
pchakraborty May 17, 2024
d4eab4d
Switch from Poetry to Rye for dependency management and packaging (#290)
pchakraborty May 21, 2024
e6dd2f2
Some engineering (#292)
pchakraborty May 31, 2024
fe56955
Fixed a bug in mepo state creation during 'mepo update-state' was fol…
pchakraborty Jun 3, 2024
42989f9
mdutils is now a dev-dependency instead of dependency (#294)
pchakraborty Jun 3, 2024
eb1eab4
A bug fix and '--serial' option for status and restore-state commands…
pchakraborty Jun 10, 2024
eb4fea3
Version 2.0.0rc4 (#297)
pchakraborty Jun 26, 2024
d2585a1
Add docs README, update main README (#272)
mathomp4 Aug 9, 2024
0da5ef4
Ready to release 2.0.0 (#298)
pchakraborty Aug 9, 2024
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
23 changes: 23 additions & 0 deletions .github/workflows/run-formatter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run formatter

on: [push]

jobs:
format:
runs-on: ubuntu-latest
name: Format code
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.lock
timeout-minutes: 5
- name: Run black
run: black --check .
timeout-minutes: 5
23 changes: 23 additions & 0 deletions .github/workflows/run-linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run linter

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
name: Lint code
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.lock
timeout-minutes: 5
- name: Run pylint
run: pylint --exit-zero src/mepo
timeout-minutes: 5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit testing of mepo
name: Run tests

on: [push]

Expand All @@ -23,9 +23,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.lock
timeout-minutes: 5

- name: Run unit tests
run: python3 mepo.d/utest/test_mepo_commands.py -v
- name: Run tests
run: |
export PYTHONPATH=$(pwd)/src:$PYTHONPATH
python tests/test_mepo_commands.py -v
timeout-minutes: 5
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
*~
*.pyc
*.egg-info
dist
venv

# This is generated by docs/make_md_docs.py
Mepo-Commands.md
.python-version
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
33 changes: 32 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

### Removed
## [2.0.0] - 2024-08-09

### Fixed

### Added

- Added `pyproject.toml` to aid with `pip` installation.

- Engineering
-- Formatting with Black
-- Linting with Pylint
-- Dependency management and packaging with Rye

- Added tests to cover more `mepo` commands

- Add new command `update-state` to permanently convert mepo1 style state to mepo2

### Changed

- Converted `mepo` to a Python project via the following renaming
-- Added `src/mepo/__init__.py`
-- Renamed `mepo.d` -> `src/mepo`
-- Renamed `mepo.d/utest` -> `tests`
-- Renamed `doc` --> `docs`
-- A `mepo` config file is now called a `mepo` registry
-- More code reorganization

- Helper script `mepo`, used for development, moved to the `bin` directory.
- Added README for `docs/make_md_docs.py` script

- State: pickle format (mepo1 style) to json format (mepo2 style)
-- If mepo1 style state is detected, print warning and suggest running `mepo update-state`

## [1.52.0] - 2024-01-10

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# mepo [![Actions Status](https://github.com/pchakraborty/mepo/workflows/Unit%20testing%20of%20mepo/badge.svg)](https://github.com/pchakraborty/mepo/actions) [![DOI](https://zenodo.org/badge/215067850.svg)](https://zenodo.org/badge/latestdoi/215067850)
# mepo [![Actions Status](https://github.com/pchakraborty/mepo/workflows/Unit%20testing%20of%20mepo/badge.svg)](https://github.com/pchakraborty/mepo/actions) [![DOI](https://zenodo.org/badge/215067850.svg)](https://zenodo.org/badge/latestdoi/215067850) [![Rye](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/rye/main/artwork/badge.json)](https://rye-up.com)

`mepo` is a tool, written in Python3 (3.6.0+), to manage (m)ultiple git r(epo)sitories, by attempting to create an illusion of a 'single repository' for multi-repository projects. Please see the [Wiki](../../wiki) for examples of `mepo` workflows.
`mepo` is a tool, written in Python3 (3.9.0+), to manage (m)ultiple git r(epo)sitories, by attempting to create an illusion of a 'single repository' for multi-repository projects. Please see the [Wiki](../../wiki) for examples of `mepo` workflows.

## Installation

`pip install mepo`

## Commands

Expand Down
17 changes: 17 additions & 0 deletions bin/mepo
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3

import os
import sys
import traceback

# Version check
if sys.version_info < (3, 9, 0):
sys.exit('ERROR: Python version needs to be >= 3.9.0')

# Add directory containing mepo to path
SRC_D = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "src")
sys.path.insert(0, SRC_D)

if __name__ == '__main__':
from mepo.__main__ import main
main()
File renamed without changes.
81 changes: 38 additions & 43 deletions doc/make_md_docs.py → docs/make_md_docs.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,49 @@
#!/usr/bin/env python3

import os
import io
import glob
from mdutils.mdutils import MdUtils
import subprocess as sp

preamble='''
preamble = """
mepo provides many different commands for working with a multi-repository fixture.
'''
"""

# Assume this script is in mepo/doc. Then we need to get to the mepo/mepo.d/command directory
doc_dir_path = os.path.dirname(os.path.realpath(__file__))
# Then we need to get to the mepo/mepo.d/command directory. First the "main" dir
main_dir_path = os.path.dirname(doc_dir_path)
# Now add 'mepo.d'
mepod_dir_path = os.path.join(main_dir_path,'mepo.d')
# And then 'command'
command_dir_path = os.path.join(mepod_dir_path,'command')
# Now add "src/mepo"
mepod_dir_path = os.path.join(main_dir_path, "src", "mepo")
# And then "command"
command_dir_path = os.path.join(mepod_dir_path, "command")

mepo_command_path = os.path.join(main_dir_path,'mepo')
mepo_command_path = os.path.join(main_dir_path, "bin", "mepo")

def get_command_list(directory):
# Walk the tree
roots = [x[0] for x in os.walk(directory)]

# Now remove "." from the list
roots = roots[1:]

# Just get the relative paths
rel_roots = [os.path.relpath(x,directory) for x in roots]

# Now exclude __pycache__
command_dirs = [x for x in rel_roots if '__pycache__' not in x]

# Convert slashes to spaces
all_commands = [x.replace('/',' ') for x in command_dirs]
def get_command_list(directory):
# Get all commands
all_commands_py = glob.glob(os.path.join(directory, "*.py"))
all_commands = [os.path.basename(x).replace(".py", "") for x in all_commands_py]

# Now let's find the commands that have subcommands
## First we get commands with spaces
commands_with_spaces = [x for x in all_commands if ' ' in x]
## Now let's just get the first elements
temp = [x.split()[0] for x in commands_with_spaces]
## Get the uniques
commands_with_subcommands = list(set(temp))

# Now remove those from our list
all_useful_commands = [x for x in all_commands if x not in commands_with_subcommands]
## First we get commands with underscore
## Then replace underscore with a space
commands_with_underscore = [x for x in all_commands if "_" in x]
commands_with_subcommands = [x.replace("_", " ") for x in commands_with_underscore]
all_useful_commands = [x for x in all_commands if x not in commands_with_underscore]
all_useful_commands += commands_with_subcommands

return sorted(all_useful_commands)


def create_markdown_from_usage(command, mdFile):
cmd = [mepo_command_path,command,'--help']
cmd = [mepo_command_path, command, "--help"]

# Some commands have spaces, so we need to break it up again
cmd = ' '.join(cmd).split()
cmd = " ".join(cmd).split()

result = sp.run(cmd,capture_output=True,universal_newlines=True,env={'COLUMNS':'256'})
result = sp.run(cmd, capture_output=True, universal_newlines=True)
output = result.stdout

output_list = output.split("\n")
Expand All @@ -66,25 +54,32 @@ def create_markdown_from_usage(command, mdFile):

# Usage
usage = output_list[0]
usage = usage.replace('usage: ','')
usage = usage.replace("usage: ", "")
mdFile.new_header(level=3, title="Usage")
mdFile.insert_code(usage)

positional_arguments = output.partition('positional arguments:\n')[2].partition('\n\n')[0]
positional_arguments = output.partition("positional arguments:\n")[2].partition(
"\n\n"
)[0]
if positional_arguments:
mdFile.new_header(level=3, title="Positional Arguments")
mdFile.insert_code(positional_arguments)

optional_arguments = output.partition('optional arguments:\n')[2].partition('\n\n')[0]
optional_arguments = output.partition("optional arguments:\n")[2].partition("\n\n")[
0
]
# Remove extra blank lines
optional_arguments = os.linesep.join([s for s in optional_arguments.splitlines() if s])
optional_arguments = os.linesep.join(
[s for s in optional_arguments.splitlines() if s]
)
if optional_arguments:
mdFile.new_header(level=3, title="Optional Arguments")
mdFile.insert_code(optional_arguments)


if __name__ == "__main__":

doc_file='Mepo-Commands.md'
doc_file = "Mepo-Commands.md"
mdFile = MdUtils(file_name=doc_file)

mdFile.new_header(level=1, title="Overview")
Expand All @@ -94,9 +89,9 @@ def create_markdown_from_usage(command, mdFile):
command_list = get_command_list(command_dir_path)
for command in command_list:
mdFile.new_header(level=2, title=command)
create_markdown_from_usage(command,mdFile)
print(f"mepo command: {command}")
create_markdown_from_usage(command, mdFile)

mdFile.new_table_of_contents(table_title='Table of Contents', depth=2)
mdFile.new_table_of_contents(table_title="Table of Contents", depth=2)
mdFile.create_md_file()
print(f'Generated {doc_file}.')

print(f"Generated {doc_file}.")
17 changes: 0 additions & 17 deletions mepo

This file was deleted.

58 changes: 0 additions & 58 deletions mepo.d/cmdline/branch_parser.py

This file was deleted.

Loading