Circular references in files or scripts occur when entities in a series sequentially reference one another and a last entity in the series references a first entity in a loop. These circular references need to be resolved before the files or scripts undergo a single-pass validation procedure. Otherwise, the files or scripts may not be validated using the single-pass validation procedure prior to deployment.
The present disclosure, in accordance with one or more various embodiments, is described in detail with reference to the following figures. The figures are provided for purposes of illustration only and merely depict typical or example embodiments.
The figures are not exhaustive and do not limit the present disclosure to the precise form disclosed.
Files or scripts (hereinafter “files”)may be written in a declarative format, such as Extensible Markup Language (XML), YAML Ain't Markup Language (YAML), JavaScript Object Notation (JSON), Initialization (INI), or HashiCorp Configuration Language (HCL), and prone to circular references. Current approaches of reordering or rearranging the configuration file do not resolve circular references and may detrimentally impact readability. These approaches include, for example, reordering all declarations of entities to occur before any references regardless of types of entities referred to, and splitting context associated with the references on a per-entity basis. However, this approach may break up code that was intended to be organized in a single combined block by separating a declaration that was originally within another declaration into a separate block, which may cause confusion to a reader and sometimes errors when deploying or running the code. Another approach is assuming auto-creation or automatic declaration of any entity that was not declared prior to reference. However, such an approach may run counter to a user's intent, while unnecessarily consuming memory.
In particular, these approaches that handle circular references either do not rectify circular references, require multiple passes to detect the circular references, or introduce potentially invalid assumptions that any forward reference is valid. These circular references, if not addressed, may prevent validation during a single-pass validation process because of an inability of the validation process to resolve the circular references or detect that an entity has been declared after it was referenced. Thus, a technique to handle circular references would improve an effectiveness and efficiency of a single-pass validation process.
As a result, entities (i.e. objects or structs) such as variables, data structures, functions, or methods, may be properly declared before a reference to that entity, while obviating back-and-forth interactions with a user to resolve the circular references. The validation process may then confirm whether the file is syntactically and semantically correct, in only a single pass.
In some embodiments, as shown in
In some examples, the database 112 may include a machine learning model that is trained to incorporate an intent of a user from the client 101. For example, the machine learning model may be trained via feedback from the user of the client 101 and/or feedback received from the device or server 120 in an event of a semantically or syntactically incorrect portion of code in the file 140 that may nonetheless be intended as a definition of, a declaration of, or a reference to an entity that was included elsewhere in the file 140. As a particular example, if the file 140 includes a misspelling of an entity by one letter, such as “rout-map” or “route map” not including a hyphen, or has an extra space in an entity name, the machine learning model may infer that the user may have intended a closely matching entity such as “route-map,” and indicate a probability of such intent. In some examples, the machine learning model may be trained using a dataset that includes previous mistakes specific to the user. By incorporating the machine learning model, the computing component 111 may, based on an assumption of a user-specific intent, avoid an incorrect assumption of a reference to an entity being before or without any declaration of that entity.
In
Other references, “route-map MyRouteMap,” “ip ospf,” and “area 77,” in lines 4 and 8, respectively, include preceding declarations in lines 1, 3, and 5, respectively. The computing component 111 may further identify definitions of an entity, such as, “vlan 66” in line 6, “interface vlan66” in lines 7 to 9, “route-map MyRouteMap” in lines 1 to 2, “ip ospf 88” in lines 3 to 5, and “area 77” in line 5.
In the output 141, the computing component 111 may identify any command that includes a reference to an entity before any corresponding definition of the entity. Entities that have respective references that lack preceding definitions corresponding to the respective references may be referred to as second entities. For example, the computing component 111 may determine “interface vlan66” as a second entity because “interface vlan66” is referenced in line 2 prior to a definition of “interface vlan66” in lines 7-9 of the file 140. The computing component 111 may determine or infer respective contexts associated with the second entities using the grammar rules 130. In some embodiments, the context may include one or more third entities referenced by the second entity and one or more fourth entities that reference the second entity. In this example, third entities referenced by the second entity “interface vlan66” include “vlan 66,” “ip ospf 88,” and “area 77” because “interface vlan66” references “vlan 66.” As explained above, the “vlan66” of “interface vlan66” is a same entity as “vlan 66” which includes a space between the “vlan” and “66.” In addition, “interface vlan66” references “ip ospf 88” and “area 77” in lines 8-9 of the file 140 Fourth entities that reference the second entity include “route-map MyRouteMap” in lines 1-2 of the file 140. The computing component 111 may prepend declarations of the second entity “interface vlan66,” and declarations of the third entities and the fourth entities “vlan 66,” “ip ospf 88,” “area 77,” and “route-map MyRouteMap.” After prepending the declarations, the computing component 111 may order the prepended declarations according to an order of the declarations, or according to an order in which an entity was first referenced, in the file 140. In some examples, the second entity or entities may be ordered before at least some of, or all of, the third entities and the fourth entities. In some examples, the contexts associated with the second entities further include one or more additional entities referenced by other second entities of the second entities, although only one second entity exists in this example.
In other words, the context of a second entity may include a declaration component and a definition component. The declaration component may indicate an existence of the second entity and the definition component may include characteristics associated with the second entity. The characteristics may include one or more third entities referenced by the second entity and one or more fourth entities that reference the second entity. The computing component 111 may prepend the declaration component of the second entity before the definition component of the second entity.
As a result, as shown in
After the circular references are resolved by the server 110, the server 110 may transmit the updated file 142 to a device or server 120. Because the updated file 142 rather than the file 140 is transmitted to the device or server 120, the device or server 120 would not get stuck and/or divert resources while attempting to process circular references. In some embodiments, the updated file 142 may be command line interface (CLI) formatted. As shown in
In some embodiments, the database 122 may be updated as new programs and/or functions are introduced. The computing component 121 may, using the rules 123, identity and output, in a log 153, an entity (e.g., object) associated with an error, an error message indicating a nature of the error, a line number of the error, one or more possible fixes to the error, and/or probabilities that the possible fixes would effectively address the error. In some embodiments, the possible fixes and/or the probabilities may be determined by a machine learning model 154. The machine learning model 154 may be trained using a dataset including errors that have historically been encountered by a specific user (e.g., of the client 101) and previous fixes that have historically been deployed to resolved the encountered errors or types of the encountered errors by that specific user. For example, the machine learning model 154 may be trained via feedback from the user of the client 101 in an event of a semantically or syntactically incorrect portion of code in the updated file 142. As a particular example, if the updated file 142 includes a misspelling of an entity by one letter, such as “rout-map” or “route map” not including a hyphen, or has an extra space in an entity name, the machine learning model 154 may infer that the user may have intended to refer to a closely matching entity such as “route-map,” and indicate a probability of such intent. The probability may be determined based on an absolute and relative frequency, relative to other errors, of such an error from that user, and/or a rate in which a fix or type of fix was deployed to address a same type of error that occurred previously.
The computing component 121 may then transmit, to the computing component 111, a subset of data from the log 153. Here, a subset of data may refer to all of or a portion of the data. For example, the computing component 121 may transmit, to the computing component 111, line numbers of the updated file 142 that have failed validation, or in other words, failed to conform to syntactic or semantic requirements. The computing component 111 may include a table 160 indicating a mapping between line numbers in the updated file 142 and line numbers in the file 140, as shown in
In the output 171, the computing component 111 may identify any command that includes a reference to an entity before any corresponding definition of the entity. Entities that do have respective references that lack preceding definitions corresponding to the respective references may be referred to as second entities. For example, the computing component 111 may determine “interface vlan66” as a second entity because “interface vlan66” is referenced in lines 2 and 4 prior to a definition of “interface vlan66” in 12-13 of the file 170. The computing component 111 may determine or infer respective contexts associated with the second entities using the grammar rules 130 and 131, as shown in
At step 206, the hardware processor(s) 202 may execute machine-readable/machine-executable instructions stored in the machine-readable storage media 204 to receive, from a client such as the client 101 of
At step 306, the hardware processor(s) 302 may execute machine-readable/machine-executable instructions stored in the machine-readable storage media 304 to determine, using logic and grammar rules, one or more entities in a file, such as a configuration file, that are forward referencing, which may mean, for example, that an entity has been referenced without a preceding declaration. The logic and the grammar rules may detect declarations, definitions, and references of entities in a configuration file and detect one or more forward references in which a reference to an entity lacks a preceding definition corresponding to the reference in the configuration file. At step 308, the hardware processor(s) 302 may execute machine-readable/machine-executable instructions stored in the machine-readable storage media 304 to prepend declarations of the forward referencing entities before the respective references to the forward referencing entities in the configuration file.
At step 406, the hardware processor(s) 402 may execute machine-readable/machine-executable instructions stored in the machine-readable storage media 404 to infer respective contexts associated with the forward referencing entities. Each of the respective contexts may include one or more other entities referenced by a forward referencing entity and one or more additional entities that the forward referencing entity references. At step 408, the hardware processor(s) 402 may execute machine-readable/machine-executable instructions stored in the machine-readable storage media 404 to prepend the declarations of each of the forward referencing entities before declarations of the other entities and the additional entities. Following step 408, the hardware processor(s) 402 may execute any one or more of steps 410, 412, and 414. In step 410, the hardware processor(s) 402 may remove a definition of an entity, out of the entities, that is identical to a prior declaration of the entity. In step 412, the hardware processor(s) 402 may remove a declaration of an entity for which a corresponding definition occurs prior to a reference of the entity. In step 414, following either step 408, 410, or 412, the hardware processor(s) 402 may reorder the prepended declarations of the forward referencing entities based on an order of respective references of the forward referencing entities.
At step 506, the hardware processor(s) 502 may execute machine-readable/machine-executable instructions stored in the machine-readable storage media 504 to receive, from a server, such as the server 110 of
The computer system 600 also includes a main memory 606, such as a random access memory (RAM), cache and/or other dynamic storage devices, coupled to bus 602 for storing information and instructions to be executed by processor 604. Main memory 606 also may be used for storing temporary variables or other intermediate information during execution of instructions to be executed by processor 604. Such instructions, when stored in storage media accessible to processor 604, render computer system 600 into a special-purpose machine that is customized to perform the operations specified in the instructions.
The computer system 600 further includes a read only memory (ROM) 608 or other static storage device coupled to bus 602 for storing static information and instructions for processor 604. A storage device 610, such as a magnetic disk, optical disk, or USB thumb drive (Flash drive), etc., is provided and coupled to bus 602 for storing information and instructions.
The computer system 600 may be coupled via bus 602 to a display 612, such as a liquid crystal display (LCD) (or touch screen), for displaying information to a computer user. An input device 614, including alphanumeric and other keys, is coupled to bus 602 for communicating information and command selections to processor 604. Another type of user input device is cursor control 616, such as a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 604 and for controlling cursor movement on display 612. In some embodiments, the same direction information and command selections as cursor control may be implemented via receiving touches on a touch screen without a cursor.
The computing system 600 may include a user interface module to implement a GUI that may be stored in a mass storage device as executable software codes that are executed by the computing device(s). This and other modules may include, by way of example, components, such as software components, object-oriented software components, class components and task components, processes, functions, attributes, procedures, subroutines, segments of program code, drivers, firmware, microcode, circuitry, data, databases, data structures, tables, arrays, and variables.
In general, the word “component,” “system,” “engine,” “database,” data store,” and the like, as used herein, can refer to logic embodied in hardware or firmware, or to a collection of software instructions, possibly having entry and exit points, written in a programming language, such as, for example, Python, Java, Go, C#, C, C++, JavaScript, Ruby, or Visual Basic. A software component may be compiled and linked into an executable program, installed in a dynamic link library, or may be written in an interpreted programming language such as, for example, BASIC, Perl, or Python. It will be appreciated that software components may be callable from other components or from themselves, and/or may be invoked in response to detected events or interrupts. Software components configured for execution on computing devices may be provided on a computer readable medium, such as a compact disc, digital video disc, flash drive, magnetic disc, or any other tangible medium, or as a digital download (and may be originally stored in a compressed or installable format that requires installation, decompression or decryption prior to execution). Such software code may be stored, partially or fully, on a memory device of the executing computing device, for execution by the computing device. Software instructions may be embedded in firmware, such as an EPROM. It will be further appreciated that hardware components may be comprised of connected logic units, such as gates and flip-flops, and/or may be comprised of programmable units, such as programmable gate arrays or processors.
The computer system 600 may implement the techniques described herein using customized hard-wired logic, one or more ASICs or FPGAs, firmware and/or program logic which in combination with the computer system causes or programs computer system 600 to be a special-purpose machine. According to one embodiment, the techniques herein are performed by computer system 600 in response to processor(s) 604 executing one or more sequences of one or more instructions contained in main memory 606. Such instructions may be read into main memory 606 from another storage medium, such as storage device 610. Execution of the sequences of instructions contained in main memory 606 causes processor(s) 604 to perform the process steps described herein. In alternative embodiments, hard-wired circuitry may be used in place of or in combination with software instructions.
The term “non-transitory media,” and similar terms, as used herein refers to any media that store data and/or instructions that cause a machine to operate in a specific fashion. Such non-transitory media may comprise non-volatile media and/or volatile media. Non-volatile media includes, for example, optical or magnetic disks, such as storage device 610. Volatile media includes dynamic memory, such as main memory 606. Common forms of non-transitory media include, for example, a floppy disk, a flexible disk, hard disk, solid state drive, magnetic tape, or any other magnetic data storage medium, a CD-ROM, any other optical data storage medium, any physical medium with patterns of holes, a RAM, a PROM, and EPROM, a FLASH-EPROM, NVRAM, any other memory chip or cartridge, and networked versions of the same.
Non-transitory media is distinct from but may be used in conjunction with transmission media. Transmission media participates in transferring information between non-transitory media. For example, transmission media includes coaxial cables, copper wire and fiber optics, including the wires that comprise bus 602. Transmission media can also take the form of acoustic or light waves, such as those generated during radio-wave and infra-red data communications.
The computer system 600 also includes a communication interface 618 coupled to bus 602. Network interface 618 provides a two-way data communication coupling to one or more network links that are connected to one or more local networks. For example, communication interface 618 may be an integrated services digital network (ISDN) card, cable modem, satellite modem, or a modem to provide a data communication connection to a corresponding type of telephone line. As another example, network interface 618 may be a local area network (LAN) card to provide a data communication connection to a compatible LAN (or WAN component to communicated with a WAN). Wireless links may also be implemented. In any such implementation, network interface 618 sends and receives electrical, electromagnetic or optical signals that carry digital data streams representing various types of information.
A network link typically provides data communication through one or more networks to other data devices. For example, a network link may provide a connection through local network to a host computer or to data equipment operated by an Internet Service Provider (ISP). The ISP in turn provides data communication services through the world wide packet data communication network now commonly referred to as the “Internet.” Local network and Internet both use electrical, electromagnetic or optical signals that carry digital data streams. The signals through the various networks and the signals on network link and through communication interface 618, which carry the digital data to and from computer system 600, are example forms of transmission media.
The computer system 600 can send messages and receive data, including program code, through the network(s), network link and communication interface 618. In the Internet example, a server might transmit a requested code for an application program through the Internet, the ISP, the local network and the communication interface 618.
The received code may be executed by processor 604 as it is received, and/or stored in storage device 610, or other non-volatile storage for later execution.
Each of the processes, methods, and algorithms described in the preceding sections may be embodied in, and fully or partially automated by, code components executed by one or more computer systems or computer processors comprising computer hardware. The one or more computer systems or computer processors may also operate to support performance of the relevant operations in a “cloud computing” environment or as a “software as a service” (SaaS). The processes and algorithms may be implemented partially or wholly in application-specific circuitry. The various features and processes described above may be used independently of one another, or may be combined in various ways. Different combinations and sub-combinations are intended to fall within the scope of this disclosure, and certain method or process blocks may be omitted in some implementations. The methods and processes described herein are also not limited to any particular sequence, and the blocks or states relating thereto can be performed in other sequences that are appropriate, or may be performed in parallel, or in some other manner. Blocks or states may be added to or removed from the disclosed example embodiments. The performance of certain of the operations or processes may be distributed among computer systems or computers processors, not only residing within a single machine, but deployed across a number of machines.
As used herein, a circuit might be implemented utilizing any form of hardware, software, or a combination thereof. For example, one or more processors, controllers, ASICs, PLAs, PALs, CPLDs, FPGAs, logical components, software routines or other mechanisms might be implemented to make up a circuit. In implementation, the various circuits described herein might be implemented as discrete circuits or the functions and features described can be shared in part or in total among one or more circuits. Even though various features or elements of functionality may be individually described or claimed as separate circuits, these features and functionality can be shared among one or more common circuits, and such description shall not require or imply that separate circuits are required to implement such features or functionality. Where a circuit is implemented in whole or in part using software, such software can be implemented to operate with a computing or processing system capable of carrying out the functionality described with respect thereto, such as computer system 600.
As used herein, the term “or” may be construed in either an inclusive or exclusive sense. Moreover, the description of resources, operations, or structures in the singular shall not be read to exclude the plural. Conditional language, such as, among others, “can,” “could,” “might,” or “may,” unless specifically stated otherwise, or otherwise understood within the context as used, is generally intended to convey that certain embodiments include, while other embodiments do not include, certain features, elements and/or steps.
Terms and phrases used in this document, and variations thereof, unless otherwise expressly stated, should be construed as open ended as opposed to limiting. Adjectives such as “conventional,” “traditional,” “normal,” “standard,” “known,” and terms of similar meaning should not be construed as limiting the item described to a given time period or to an item available as of a given time, but instead should be read to encompass conventional, traditional, normal, or standard technologies that may be available or known now or at any time in the future. The presence of broadening words and phrases such as “one or more,” “at least,” “but not limited to” or other like phrases in some instances shall not be read to mean that the narrower case is intended or required in instances where such broadening phrases may be absent.