Persist json file with the upstream steps structure, that is step names and their connections.
13811
def persist_upstream_structure(self):
        """"""
        persist_dir = os.path.join(self.experiment_directory, '{}_upstream_structure.json'.format(self.name))
        logger.info('Step {}, saving upstream pipeline structure to {}'.format(self.name, persist_dir))
        joblib.dump(self.upstream_structure, persist_dir)
851310
function commitStep( $package, $http, $step, &$persistentData, $tpl )
    {
        $methodMap = $this->commitStepMethodMap();
        if ( count( $methodMap ) > 0 )
        {
            if ( isset( $methodMap[$step['id']] ) )
            {
                $method = $methodMap[$step['id']];
                return $this->$method( $package, $http, $step, $persistentData, $tpl );
            }
        }
    }
91293
def _save_json(self, filename):
        """"""
        with open(filename, 'w') as file_handle:
            json.dump(self._sensors, file_handle, cls=MySensorsJSONEncoder,
                      indent=4)
            file_handle.flush()
            os.fsync(file_handle.fileno())
976680
public static void saveJson(File json, Object object) throws IOException {
        objectMapper.writer().writeValue(json, object);
    }
465158
def set_parameters_upstream(self, parameters):
        
        assert isinstance(parameters, dict), 'parameters must be dict, got {} instead'.format(type(parameters))
        for step_obj in self.all_upstream_steps.values():
            for key in step_obj.__dict__.keys():
                if key in list(parameters.keys()):
                    step_obj.__dict__[key] = parameters[key]
                    if key == 'experiment_directory':
                        step_obj._prepare_experiment_directories()
        logger.info('set new values to all upstream Steps including this Step.')
        return self
345903
def put_stream(self, rel_path, metadata=None, cb=None):
        

        class flo:

            def __init__(self, this, sink, upstream, repo_path):
                self.this = this
                self.sink = sink
                self.upstream = upstream
                self.repo_path = repo_path

            @property
            def repo_path(self):
                return self.repo_path

            def write(self, d):
                self.sink.write(d)

                if self.upstream:
                    self.upstream.write(d)

            def writelines(self, lines):
                raise NotImplemented()

            def close(self):
                self.sink.close()

                size = os.path.getsize(self.repo_path)

                self.this.add_record(rel_path, size)
                self.this._free_up_space(size, this_rel_path=rel_path)

                if self.upstream:
                    self.upstream.close()
                    
            def __enter__(self): # Can be used as a context!
                return self

            def __exit__(self, type_, value, traceback):
                if type_:
                    return False

        if not isinstance(rel_path, basestring):
            rel_path = rel_path.cache_key

        repo_path = os.path.join(self.cache_dir, rel_path.strip('/'))

        if not os.path.isdir(os.path.dirname(repo_path)):
            os.makedirs(os.path.dirname(repo_path))

        self.put_metadata(rel_path, metadata=metadata)

        sink = open(repo_path, 'w+')
        upstream = self.upstream.put_stream(
            rel_path,
            metadata=metadata) if self.upstream else None

        return flo(self, sink, upstream, repo_path)
604730
def save(self, key, data):
        
        self._db[key] = json.dumps(data)
        self._db.sync()
1163716
def process_all_json_files(build_dir):
    """"""
    html_files = []
    for root, _, files in os.walk(build_dir):
        for filename in fnmatch.filter(files, '*.fjson'):
            if filename in ['search.fjson', 'genindex.fjson',
                            'py-modindex.fjson']:
                continue
            html_files.append(os.path.join(root, filename))
    page_list = []
    for filename in html_files:
        try:
            result = process_file(filename)
            if result:
                page_list.append(result)
        # we're unsure which exceptions can be raised
        except:  # noqa
            pass
    return page_list
236213
def save_json(object, handle, indent=2):
    """"""
    obj_json = json.dumps(object, indent=indent, cls=NumpyJSONEncoder)
    handle.write(obj_json)
1321960
private function deserializeStep(Path $path, $data, array &$stepIds, array $options = [])
    {
        if (in_array(Options::REFRESH_UUID, $options)) {
            $step = new Step();
        } else {
            $step = $this->stepRepo->findOneBy(['uuid' => $data['id']]) ?? new Step();
            $step->setUuid($data['id']);
        }

        $step->setPath($path);

        $stepIds[] = $step->getUuid();

        if (isset($data['title'])) {
            $step->setTitle($data['title']);
        }
        if (isset($data['description'])) {
            $step->setDescription($data['description']);
        }
        if (isset($data['poster'])) {
            $step->setPoster($data['poster']['url']);
        }

        if (isset($data['display'])) {
            if (isset($data['display']['numbering'])) {
                $step->setNumbering($data['display']['numbering']);
            }
            if (isset($data['display']['height'])) {
                $step->setActivityHeight($data['display']['height']);
            }
        }

        /* Set primary resource */
        $resource = isset($data['primaryResource']['id']) ?
            $this->resourceNodeRepo->findOneBy(['uuid' => $data['primaryResource']['id']]) :
            null;
        $step->setResource($resource);

        if (isset($data['showResourceHeader'])) {
            $step->setShowResourceHeader($data['showResourceHeader']);
        }

        // Set secondary resources
        if (isset($data['secondaryResources'])) {
            $step->emptySecondaryResources();

            foreach ($data['secondaryResources'] as $index => $resourceData) {
                $secondaryResource = new SecondaryResource();
                $secondaryResource->setOrder($index);

                /** @var ResourceNode $resource */
                $resource = $this->resourceNodeRepo->findOneBy(['uuid' => $resourceData['id']]);
                $secondaryResource->setResource($resource);

                $step->addSecondaryResource($secondaryResource);
            }
        }

        // Set children steps
        if (isset($data['children'])) {
            $step->emptyChildren();

            foreach ($data['children'] as $childIndex => $childData) {
                $child = $this->deserializeStep($path, $childData, $stepIds, $options);

                $child->setOrder($childIndex);
                $step->addChild($child);
            }
        }

        return $step;
    }
554441
def save(self):
        '''  '''
        redis = type(self).get_redis()
        pipe = to_pipeline(redis)

        pipe.hset(self.key(), 'id', self.id)

        for fieldname, field in self.proxy:
            if not isinstance(field, Relation):
                field.save(getattr(self, fieldname), pipe, commit=False)

        pipe.sadd(type(self).members_key(), self.id)

        pipe.execute()

        if self.notify:
            data = json.dumps({
                'event': 'create' if not self._persisted else 'update',
                'data': self.to_json(),
            })
            redis.publish(type(self).cls_key(), data)
            redis.publish(self.key(), data)

        self._persisted = True

        return self
1049797
def save
      json = MultiJson.encode(attributes)
      File.open(file, 'w') {|f| f.write(json) }
    end
778224
def store_data(data):
    
    with open(url_json_path) as json_file:
        try:
            json_file_data = load(json_file)
            json_file_data.update(data)
        except (AttributeError, JSONDecodeError):
            json_file_data = data
    with open(url_json_path, 'w') as json_file:
        dump(json_file_data, json_file, indent=4, sort_keys=True)
1347369
private function SaveTypeDefToJson()
    {
        $typedefs = array();
        
        foreach($this->symbols->headers as $header)
        {
            if(!$header->HasTypeDefs())
                continue;
            
            foreach($header->namespaces as $namespace)
            {
                if(!$namespace->HasTypeDefs())
                    continue;
                
                foreach($namespace->type_definitions as $typedef)
                {
                    if(trim($typedef->description))
                    {
                        $typedefs[$header->name][$namespace->name]
                            [$typedef->name] = [
                                "type" => $typedef->original_type,
                                "description" => $typedef->description
                            ]
                        ;
                    }
                    else
                    {
                        $typedefs[$header->name][$namespace->name]
                            [$typedef->name] = [
                                "type" => $typedef->original_type
                            ]
                        ;
                    }
                }
            }
        }
        
        if(count($typedefs) > 0)
        {
            file_put_contents(
                $this->definitions_path . "type_definitions.json", 
                Json::Encode($typedefs)
            );

            unset($typedefs);
        }
    }
144290
def save_metadata(self, phase, data_name):
        
        with open("{}/.metadata".format(make_path(phase)), "w+") as f:
            f.write("pipeline={}\nphase={}\ndata={}".format(self.pipeline_name, phase.phase_name,
                                                            data_name))
386671
public function persist()
    {
        $this->validate();

        if (!is_array($this->data)) {
            $this->data = [$this->data];
        }

        $append = $this instanceof StreamCollectorInterface;
        $patches = $this->jsonPatch->generateArrayAdd($this->getPath(), $this->data, $append);
        $this->dataSource->save($this->process, $patches);

        $this->data = [];
    }
606909
def to_json(self) -> Dict:
        """"""
        rv = {
            'network_ids': self.network_ids,
        }

        if self.seeding:
            rv['seeding'] = self.seeding.to_json()

        if self.pipeline:
            rv['pipeline'] = self.pipeline.to_json()

        return rv