Skip to content

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 representation
  • call_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 DeprecationWarning
  • combine_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

  1. Cleaner API:
  2. output + 10 instead of output.map(lambda x: x + 10)
  3. output['field'] instead of output.map(lambda x: x['field'])

  4. Better Type Safety: Operations only available for appropriate types

  5. Proper Context Handling: All operations preserve ResolutionContext

  6. 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

  1. Gradually migrate existing code to use new operators
  2. Monitor for any issues with the new implementation
  3. Plan removal of deprecated features for next major version