RuntimeValue Migration Status
Completed Tasks ✅
1. Analysis Phase
- Analyzed usage of MappedValue and CombinedValue across codebase
- Reviewed all RuntimeValue implementations
- Created comprehensive migration plan
2. Implementation Phase
- Added RuntimeValueOps mixin to all RuntimeValue implementations:
- ResourceOutput
- ResourceOutputWithContext
- VariableReference
- LocalReference
- ConstantValue
- NetherframeFunction
- ConditionalExpression
-
NativeRuntimeToken (already had it)
-
Enhanced RuntimeValueOps with new operators:
__str__()- String representation for synthesis__format__()- Format runtime values__repr__()- Developer-friendly representationcall_method()- Call methods on runtime values-
get()- Get from dict-like values with default -
Created context-preserving wrapper classes:
- OperatorResult - For binary operators
- UnaryOperatorResult - For unary operators
- TransformResult - For transformations
- IndexResult - For indexing operations
-
MethodCallResult - For method calls
-
Fixed context passing in operators:
- All operators now properly preserve ResolutionContext
-
No more
resolve(None)calls in operators -
Added deprecation warnings:
map()methods now issue DeprecationWarningcombine_deferred()function issues DeprecationWarning- Both still work for backward compatibility
3. Testing
- Created comprehensive test suite for new operator-based API
- All new tests passing
- Backward compatibility maintained - old tests still pass
Remaining Tasks 📋
1. Migration of Existing Code (Medium Priority)
- Replace
.map()calls throughout codebase with operators - Replace
combine_deferred()calls with operators - Update examples to use new patterns
2. Cleanup (Low Priority - After 1 Release Cycle)
- Remove MappedValue class
- Remove CombinedValue class
- Remove deprecated map() methods
- Remove combine_deferred() function
3. Documentation (Low Priority)
- Update API documentation
- Add migration guide for users
- Update examples in docs
Benefits Achieved
- Cleaner API:
output + 10instead ofoutput.map(lambda x: x + 10)-
output['field']instead ofoutput.map(lambda x: x['field']) -
Better Type Safety: Operations only available for appropriate types
-
Proper Context Handling: All operations preserve ResolutionContext
-
Backward Compatibility: Old code continues to work with deprecation warnings
Migration Examples
# OLD: Using map()
upper_name = resource.name.map(str.upper)
# NEW: Using call_method()
upper_name = resource.name.call_method("upper")
# OLD: Using combine_deferred()
result = combine_deferred(lambda a, b: a + b, x, y)
# NEW: Using operators
result = x + y
# OLD: Complex transformation
result = output.map(lambda x: f"prefix-{x}-suffix")
# NEW: Using f-string with TransformResult
from nf.core.runtime_value_wrapped import TransformResult
result = TransformResult(output, lambda x: f"prefix-{x}-suffix")
Next Steps
- Gradually migrate existing code to use new operators
- Monitor for any issues with the new implementation
- Plan removal of deprecated features for next major version