Skip to content

Commit 99e5193

Browse files
authored
Merge pull request #1 from reward-protocol/dual_import
prepareing for rename by allowing dual import
2 parents 8c22fd8 + 7c8442c commit 99e5193

11 files changed

Lines changed: 1382 additions & 29 deletions

File tree

reward_kit/_version.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ def git_versions_from_keywords(
255255
"error": None,
256256
"date": date,
257257
}
258-
# no suitable tags, so version is "0+unknown", but full hex is still there
258+
# no suitable tags, so version is "0.4.0+unknown", but full hex is still there
259259
if verbose:
260260
print("no suitable tags, using unknown + full revision id")
261261
return {
262-
"version": "0+unknown",
262+
"version": "0.4.0+unknown",
263263
"full-revisionid": keywords["full"].strip(),
264264
"dirty": False,
265265
"error": "no suitable tags",
@@ -435,7 +435,7 @@ def render_pep440(pieces: Dict[str, Any]) -> str:
435435
rendered += ".dirty"
436436
else:
437437
# exception #1
438-
rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"])
438+
rendered = "0.4.0+untagged.%d.g%s" % (pieces["distance"], pieces["short"])
439439
if pieces["dirty"]:
440440
rendered += ".dirty"
441441
return rendered
@@ -461,7 +461,7 @@ def render_pep440_branch(pieces: Dict[str, Any]) -> str:
461461
rendered += ".dirty"
462462
else:
463463
# exception #1
464-
rendered = "0"
464+
rendered = "0.4.0"
465465
if pieces["branch"] != "master":
466466
rendered += ".dev0"
467467
rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"])
@@ -500,7 +500,7 @@ def render_pep440_pre(pieces: Dict[str, Any]) -> str:
500500
rendered = pieces["closest-tag"]
501501
else:
502502
# exception #1
503-
rendered = "0.post0.dev%d" % pieces["distance"]
503+
rendered = "0.4.0.post0.dev%d" % pieces["distance"]
504504
return rendered
505505

506506

@@ -524,7 +524,7 @@ def render_pep440_post(pieces: Dict[str, Any]) -> str:
524524
rendered += "g%s" % pieces["short"]
525525
else:
526526
# exception #1
527-
rendered = "0.post%d" % pieces["distance"]
527+
rendered = "0.4.0.post%d" % pieces["distance"]
528528
if pieces["dirty"]:
529529
rendered += ".dev0"
530530
rendered += "+g%s" % pieces["short"]
@@ -551,7 +551,7 @@ def render_pep440_post_branch(pieces: Dict[str, Any]) -> str:
551551
rendered += ".dirty"
552552
else:
553553
# exception #1
554-
rendered = "0.post%d" % pieces["distance"]
554+
rendered = "0.4.0.post%d" % pieces["distance"]
555555
if pieces["branch"] != "master":
556556
rendered += ".dev0"
557557
rendered += "+g%s" % pieces["short"]
@@ -576,7 +576,7 @@ def render_pep440_old(pieces: Dict[str, Any]) -> str:
576576
rendered += ".dev0"
577577
else:
578578
# exception #1
579-
rendered = "0.post%d" % pieces["distance"]
579+
rendered = "0.4.0.post%d" % pieces["distance"]
580580
if pieces["dirty"]:
581581
rendered += ".dev0"
582582
return rendered
@@ -688,7 +688,7 @@ def get_versions() -> Dict[str, Any]:
688688
root = os.path.dirname(root)
689689
except NameError:
690690
return {
691-
"version": "0+unknown",
691+
"version": "0.4.0+unknown",
692692
"full-revisionid": None,
693693
"dirty": None,
694694
"error": "unable to find root of source tree",
@@ -708,7 +708,7 @@ def get_versions() -> Dict[str, Any]:
708708
pass
709709

710710
return {
711-
"version": "0+unknown",
711+
"version": "0.4.0+unknown",
712712
"full-revisionid": None,
713713
"dirty": None,
714714
"error": "unable to compute version",

reward_kit/cli_commands/deploy.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,51 @@
1515
import yaml # For saving config if save_config helper doesn't exist
1616

1717
# TODO: Consider moving subprocess_manager functions to a more central location if used by core CLI
18-
from development.utils.subprocess_manager import (
19-
start_ngrok_and_get_url, # Added ngrok function
20-
)
21-
from development.utils.subprocess_manager import (
22-
start_process,
23-
start_serveo_and_get_url,
24-
stop_process,
25-
)
18+
try:
19+
from development.utils.subprocess_manager import (
20+
start_ngrok_and_get_url, # Added ngrok function
21+
start_process,
22+
start_serveo_and_get_url,
23+
stop_process,
24+
)
25+
except ImportError:
26+
# Fallback implementations when development module is not available
27+
import subprocess
28+
import signal
29+
import socket
30+
31+
def start_process(command, log_path, env=None):
32+
"""Fallback process starter."""
33+
try:
34+
with open(log_path, 'w') as log_file:
35+
process = subprocess.Popen(
36+
command,
37+
stdout=log_file,
38+
stderr=subprocess.STDOUT,
39+
env=env
40+
)
41+
return process
42+
except Exception as e:
43+
print(f"Error starting process: {e}")
44+
return None
45+
46+
def stop_process(pid):
47+
"""Fallback process stopper."""
48+
try:
49+
import os
50+
os.kill(pid, signal.SIGTERM)
51+
except Exception:
52+
pass
53+
54+
def start_serveo_and_get_url(local_port, log_path):
55+
"""Fallback serveo tunnel - returns None to indicate unavailable."""
56+
print("Serveo tunneling not available - development module not found")
57+
return None, None
58+
59+
def start_ngrok_and_get_url(local_port, log_path):
60+
"""Fallback ngrok tunnel - returns None to indicate unavailable."""
61+
print("ngrok tunneling not available - development module not found")
62+
return None, None
2663
from reward_kit.auth import get_fireworks_account_id
2764
from reward_kit.config import GCPCloudRunConfig, RewardKitConfig
2865
from reward_kit.config import _config_file_path as global_loaded_config_path

reward_protocol/__init__.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Fireworks Reward Protocol - Simplify reward modeling for LLM RL fine-tuning.
3+
4+
This package provides an alternative import name for reward_kit.
5+
All functionality from reward_kit is available through reward_protocol.
6+
7+
A Python library for defining, testing, deploying, and using reward functions
8+
for LLM fine-tuning, including launching full RL jobs on the Fireworks platform.
9+
10+
The library also provides an agent evaluation framework for testing and evaluating
11+
tool-augmented models using self-contained task bundles.
12+
"""
13+
14+
# Re-export everything from reward_kit
15+
from reward_kit import *
16+
from reward_kit import __version__
17+
18+
# Make sure all public symbols are available
19+
from reward_kit import __all__
20+
21+
# Additional convenience imports for common submodules
22+
from reward_kit import (
23+
adapters,
24+
agent,
25+
auth,
26+
cli,
27+
cli_commands,
28+
common_utils,
29+
config,
30+
datasets,
31+
evaluation,
32+
execution,
33+
gcp_tools,
34+
generation,
35+
generic_server,
36+
integrations,
37+
mcp,
38+
mcp_agent,
39+
models,
40+
packaging,
41+
platform_api,
42+
playback_policy,
43+
resources,
44+
reward_function,
45+
rewards,
46+
rl_processing,
47+
server,
48+
typed_interface,
49+
utils,
50+
)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name="reward-kit",
77
version=versioneer.get_version(),
88
cmdclass=versioneer.get_cmdclass(),
9-
packages=find_packages(),
9+
packages=find_packages(include=["reward_kit*", "reward_protocol*", "development*"]),
1010
install_requires=[
1111
"requests>=2.25.0",
1212
"pydantic>=2.0.0",
@@ -68,6 +68,7 @@
6868
"console_scripts": [
6969
"fireworks-reward=reward_kit.cli:main",
7070
"reward-kit=reward_kit.cli:main",
71+
"reward-protocol=reward_kit.cli:main",
7172
],
7273
},
7374
author="Fireworks AI",
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Reward Protocol Tests
2+
3+
This directory contains tests specifically for verifying the `reward_protocol` dual import functionality.
4+
5+
## Test Files
6+
7+
### `test_reward_protocol_import.py`
8+
- Comprehensive pytest-compatible test suite
9+
- Tests import equivalence between `reward_kit` and `reward_protocol`
10+
- Verifies that both packages provide identical functionality
11+
- Tests require all dependencies to be installed
12+
13+
### `test_reward_protocol_simple.py`
14+
- Basic import tests that work with a fully installed environment
15+
- Tests that both packages can be imported and provide the same functionality
16+
- Verifies version consistency and API equivalence
17+
18+
### `test_minimal_structure.py`
19+
- Structure verification tests that work without dependencies
20+
- Tests package discovery, file structure, and configuration
21+
- Verifies that the build process includes both packages
22+
-**Passes in development environment**
23+
24+
### `test_import_equivalence.py`
25+
- Tests import equivalence by examining module structure
26+
- Verifies console scripts and package metadata
27+
- Tests that `reward_protocol` properly re-exports `reward_kit`
28+
-**Passes in development environment**
29+
30+
### `demo_dual_imports.py`
31+
- Demonstration script showing how dual imports work
32+
- Shows usage examples for both import styles
33+
- Provides migration guide for users
34+
- Verifies package structure and configuration
35+
36+
## Running the Tests
37+
38+
### From the project root:
39+
```bash
40+
# Run minimal structure tests (works in dev environment)
41+
python tests/reward_protocol_tests/test_minimal_structure.py
42+
43+
# Run import equivalence tests (works in dev environment)
44+
python tests/reward_protocol_tests/test_import_equivalence.py
45+
46+
# Run demo (works in dev environment)
47+
python tests/reward_protocol_tests/demo_dual_imports.py
48+
49+
# Run simple tests (requires full installation)
50+
python tests/reward_protocol_tests/test_reward_protocol_simple.py
51+
52+
# Run pytest tests (requires full installation)
53+
pytest tests/test_reward_protocol_import.py -v
54+
```
55+
56+
## Purpose
57+
58+
These tests verify that users can import the package using either:
59+
- `from reward_kit import ...` (original style)
60+
- `from reward_protocol import ...` (new style)
61+
62+
Both import styles provide identical functionality with no breaking changes.

0 commit comments

Comments
 (0)