Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
prismofeverything committed Aug 23, 2024
2 parents deb26eb + c722135 commit d544b8d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist/
build/

process_bigraph.egg-info/
out/
21 changes: 20 additions & 1 deletion process_bigraph/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
Composite, Process, and Step classes
====================================
"""

import os
import copy
import json
import math
import collections
from typing import Dict
Expand Down Expand Up @@ -710,6 +711,24 @@ def __init__(self, config=None, core=None):

# self.run_steps(self.to_run)

def save(self,
filename='one_cell_two_directions.json',
outdir='out',
):
serialized_doc = self.core.serialize(
schema=self.composition,
state=self.state,
)

# save the dictionary to a JSON file
if not os.path.exists(outdir):
os.makedirs(outdir)
filename = os.path.join(outdir, filename)

# write the new data to the file
with open(filename, 'w') as json_file:
json.dump(serialized_doc, json_file, indent=4)
print(f"Created new file: {filename}")

def reset_step_state(self, step_paths):
self.trigger_state = build_trigger_state(
Expand Down
23 changes: 3 additions & 20 deletions process_bigraph/experiments/comets.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,34 +465,17 @@ def run_comets():
'fields': ['fields']
}
},
# 'emitter': {
# '_type': 'step',
# 'address': 'local:ram-emitter',
# 'config': {
# 'emit': {
# 'fields': 'map',
# 'time': 'float',
# }
# },
# 'inputs': {
# 'fields': ['fields'],
# 'time': ['global_time']
# }
# }
}

sim = Composite({
'state': composite_state,
'emitter': {
'mode': 'all'}}, core=core)

# TODO: this should fail validation
# sim = Composite({
# 'state': composite_state,
# 'emitter': {
# 'mode': 'pluto'}}, core=core)
# save the document
sim.save(filename='comets.json', outdir='out')

sim.update({}, 10.0)
sim.update({}, 100.0)

results = sim.gather_results()

Expand Down
5 changes: 4 additions & 1 deletion process_bigraph/process_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def serialize_process(schema, value, core):
"""Serialize a process to a JSON-safe representation."""
# TODO -- need to get back the protocol: address and the config
process = value.copy()
process['config'] = core.serialize(
process['instance'].config_schema,
process['config'])
del process['instance']
return process

Expand Down Expand Up @@ -169,7 +172,7 @@ def deserialize_step(schema, encoded, core):
'_inherit': 'string'},

# TODO: have the default enum be the first option
'emitter_mode': 'enum[none,all,paths,bridge,port]',
'emitter_mode': 'enum[none,all,stores,bridge,paths,ports]',

'interval': {
'_type': 'interval',
Expand Down

0 comments on commit d544b8d

Please sign in to comment.